是否可以在弹出窗口中检测用户点击事件? [英] Is it possible to detect the user click event in the popup window?
问题描述
如果当前网址和弹出网址使用以下代码在同一个域中,我可以在弹出窗口中检测用户点击事件。
I can detect the user click event in the popup window if the current url and popup url is in same domain using the following code.
var myWindow = window.open("abc.html","MsgWindow", "width=500","height=600");
$(myWindow).on('click', 'a', function() {alert('a')});
但是,是否可以从外部URL检测用户活动,如下所示。?
But, Is it possible to detect the user activity from the external url as below.?
var myWindow = window.open("http://google.com","MsgWindow", "width=500","height=600");
$(myWindow).on('click', 'a', function() {alert('a')});
第二个片段对我不起作用。我怎样才能让它发挥作用。
The second snippet is not working for me. How can I make it work.
提前致谢。
推荐答案
不,你不能因为SOP(同源政策) http://en.wikipedia.org / wiki / Same-origin_policy
No you can't becouse of SOP (Same Origin Policy) http://en.wikipedia.org/wiki/Same-origin_policy
举个例子:
您可以使用登录信息弹出一个网页。使用您的方法,您可以跟踪登录信息的键输入。用户名和密码。那将是一个重大的安全问题。
To give you an example: You make a popup to a webpage with a login. With your method you are able to track the key input of the login information. username and password. Thats would be a major secutiry issue.
这篇关于是否可以在弹出窗口中检测用户点击事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!