0

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.

4
  • what result did u get with your example? did it work? Commented Jul 10, 2011 at 18:31
  • 2
    If you're getting a 404, then myPage.html must actually not exist! Either that, or due some permissions issues, it can't appear. Simply go to myPage.html in your browser and see if you can load it. I'm willing to bet that you can't. Commented Jul 10, 2011 at 18:32
  • Do you mean a new browser window is openned, but it does not display the page ? If so, is the URL in the new browser window right ? Or it not what you expect ? Commented Jul 10, 2011 at 18:37
  • Yeah silly I had spelled it wrong. Commented Jul 10, 2011 at 18:38

1 Answer 1

6

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;
Sign up to request clarification or add additional context in comments.

1 Comment

This code snippet is not working for Microsoft Edge browser. How can we pass args in case of Edge?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.