开发者

How to use in jQuery data from window.open

开发者 https://www.devze.com 2022-12-24 05:47 出处:网络
How to use in jQuery data from window.open w = window.open(\"http://google.com\", \'test_window\', \'left=20,top=20,width=500,height=500,toolbar=1,resizable=1\');

How to use in jQuery data from window.open

  w = window.open("http://google.com",
            'test_window',
            'left=20,top=20,width=500,height=500,toolbar=1,resizable=1');
  browser = w.document;  
  // execute commands in browser
  $(browser).ready(function(开发者_开发技巧){
    alert($('input', browser).attr('name'));
  });
  // close browser
  w.close();

In this example I want to open new pop-up window, load Google page and get information about loaded page element (name of input filed).

I try to do this, but not found solution. Please, help me.


I believe you would need to open it in an iFrame.

or create a new window (http://your-domain.com/google.html) with an iframe embeded, then you can use jQuery to query the dom of the external content.


Please tell us what are you trying to do. maybe there is a better solution. If you want to use google search stuff in your site there is a apis for that. Google search API


This is called cross site scripting (XSS). Your page (i.e. somedomain.com) is executing a script which is trying to read data off another window which has loaded a different domain (google.com). Modern browsers will prevent this since it is a security concern.

Imagine if you had a compromised site open in one window, and your bank site open in another. With XSS an attacker could sniff your bank info from the compromised site.

The only way to do such a thing is to disable XSS filters on the client (not a good idea), or install an application which does the job you are attempting to do with javascript. However, depending on what you are trying to accomplish, Google API's may offer the access you need without all that work.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号