如何使用JavaScript在IFRAME中启用右键单击 [英] How Enable Right Click in IFRAME with JavaScript

查看:112
本文介绍了如何使用JavaScript在IFRAME中启用右键单击的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

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).

如果我在该站点登录,我可以启用右键单击没有带有简单JavaScript代码的iframe,但是如果我通过我正在使用的iframe访问此网站,我无法在那里启用右键。

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

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

那么有没有办法在iframe中启用右键?即使它是外部域名?

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

谢谢

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

推荐答案

您无法以您描述的方式将Javascript注入单独域中的外部页面。抱歉。

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

这篇关于如何使用JavaScript在IFRAME中启用右键单击的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆