Friday, February 23, 2024
 Popular · Latest · Hot · Upcoming
49
rated 0 times [  54] [ 5]  / answers: 1 / hits: 10855  / 9 Years ago, fri, march 27, 2015, 12:00:00

I require the ability to open a new window



window.open(url,'_blank');


Then run a javascript script such as



window.open(url,'_blank').ready(javascript in here);


But I don't know how to do it, is there a way that I can do this?






The description is short but I think that's all that needs to be said


More From » html

 Answers
0

In short you cannot do what you are asking. The new window is sandboxed. It can only run javascript referenced within its own html file.



One possible solution that might get you what you need would be to use postMessage. Even so in order to do this the receiving page needs to be listening to potential messages.
https://developer.mozilla.org/en-US/docs/Web/API/Window/postMessage



An alternative would be to include a query param in the url and parse that param out client side in the new window and take action based on the value of the param.


[#38309] Thursday, March 26, 2015, 9 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
dajah

Total Points: 208
Total Questions: 97
Total Answers: 87

Location: Falkland Islands
Member since Mon, Jul 13, 2020
4 Years ago
;