Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

open a new window, and call javascript function

Tags:

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.

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>

Thanks,
Eran.

like image 893
user455416 Avatar asked Sep 22 '10 18:09

user455416


1 Answers

You cannot control or access a cross domain window unfortunately. This is done for security precautions. Do you have control over the other URL?

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.
like image 162
Cristian Sanchez Avatar answered Oct 13 '22 12:10

Cristian Sanchez