james
james

Reputation: 2663

Javascript window.open() passing args

I am trying to use window.open() to pass along some arguments to another page.

I want the page to be

myPage.html?img=1.jpg

Where once on that page I will use javascript to get the arg and show the image.

However I cannot figure out how to do this with window.open() cause it says the pages does not exist which I can understand.

 window.open('myPage.html?img=1.jpg','_blank')  

Hope this makes sense and I don't even know if it is possible.

Upvotes: 0

Views: 11776

Answers (1)

beardhatcode
beardhatcode

Reputation: 4753

myPage.html should exist, and check the docs on window.open

to pass vars:

var variable = "lol";
var w = window.open("http://example.com");
w.variable = variable;

or yopu can visit the opeing window:

var variable = window.opener.variable;

Upvotes: 6

Related Questions