打开一个新窗口,并调用javascript函数 [英] open a new window, and call javascript function
问题描述
我是javascript的新手。我想知道如何从一个javascript方法打开一个新窗口,然后调用它的javascript方法。
I am new to javascript. I would like to know how a new window can be opened from a javascript method, and then call it's javascript methods.
窗口的url位于另一个域中(可能导致安全问题!?),而我无法控制它。
The url of the window, is in another domain (can cause a security problem !?), and I don't have control over it.
例如,代码应符合以下条件:
For example, a code that should behave as the followings:
handler<-openAWindow("www.someurl.com");//open a window and get a handler for it
handler->someMethod1(param1, param2);//call some javascript method
handler->someMethod2(param3, param4);//call some other javascript method<br>
谢谢,
Eran。
Thanks,
Eran.
推荐答案
遗憾的是,您无法控制或访问跨域窗口。这样做是为了安全预防措施。您是否可以控制其他网址?
You cannot control or access a cross domain window unfortunately. This is done for security precautions. Do you have control over the other URL?
但是,如果该窗口位于同一个域,则您可以访问该窗口及其DOM。
However, if the window is on the same domain you do have access to the window and its DOM.
var win = window.open("/page", "title");
win.someFunction();
var el = win.document.getElementById("id123");
//etc.
这篇关于打开一个新窗口,并调用javascript函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!