如何使用 JavaScript 在 IFRAME 中启用右键单击

发布于 2024-09-16 14:57:47 字数 728 浏览 4 评论 0原文

所以我的网页中有这个 IFRAME,iframe 有一个登录页面(这是我的域的一部分),但登录后 iframe 将用户重定向到外部站点(不在我的域中),但仍然位于 iframe 内但没有右键单击选项(在该外部页面的 HTML 代码中禁用)。

如果我使用简单的 JavaScript 代码在没有 iframe 的情况下登录该网站,我可以启用右键单击,但如果我通过正在使用的 iframe 访问该网站,则无法启用右键单击。

这是我正在尝试启用右键单击的代码:

javascript:函数 r(d){d.oncontextmenu=null;d.onselectstart=null;d.ondragstart=null;d.onkeydown=null;d.onmousedown=null; d.body.oncontextmenu=null;d.body.onselectstart=null;d.body.ondragstart=null;d.body.onkeydown=null; d.body.onmousedown=null;};函数 统一(w){r(w.document);if(w.frames.length>0){for(var 我=0;我

那么有什么办法可以在 iframe 内启用右键单击吗?即使它是外部域?

谢谢

tl;dr:如何使用 javascript 或任何其他工具在 IFRAME 中启用右键单击。

So I have this IFRAME in my web page, the iframe has a login page (this is part of my domain) but then after the login the iframe redirects the user to an external site (not in my domain) but still is inside the iframe but without the option to right-click (disabled in the HTML code of that external page).

I can enable the right click if I login in that site without an iframe with a simple JavaScript code, but if I access this site through the iframe I'm using, I can't enable the right click there.

This is the code I'm using trying to enable right click:

javascript:function
r(d){d.oncontextmenu=null;d.onselectstart=null;d.ondragstart=null;d.onkeydown=null;d.onmousedown=null;
d.body.oncontextmenu=null;d.body.onselectstart=null;d.body.ondragstart=null;d.body.onkeydown=null;
d.body.onmousedown=null;};function
unify(w){r(w.document);if(w.frames.length>0){for(var
i=0;i

So is there any way to enable the right click inside an iframe? even if it is an external domain?

Thanks

tl;dr: How to enable right click in IFRAME with javascript or any other tool.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

等你爱我 2024-09-23 14:57:47

您无法按照您所描述的方式将 Javascript 注入到单独域上的外部页面中。对不起。

You cannot inject Javascript into the external page on a separate domain in the way you describe. Sorry.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文