开发者

Set onload() on a newly created window, possible?

I'm creating a Safari Extension. At one point, I want to open a new tab/window and enter text on some text fields in that new tab.

This is what I tried.

    var newWindow = window.open('http://openradar.appspot.com/myradars/add', "new tab");
    var fillContent = function () {
      //Fill some content
      //This never get called
    };

    newWindow.onload = fillContent;

The problem is that the function never get called.

During debugging, I saw that newWindow is valid开发者_StackOverflow中文版 but that newWindow.onload is always undefined, before and after newWindow.onload = fillContent;

Is it possible to do what I'm trying to do? Is there a better way?


If the page you are trying to open is in another domain, it's impossible, because you were violating javascript's same origin policy (which states that you can only 'control' pages that are on the same domain where the script is running).

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜