admin管理员组

文章数量:1317898

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.

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.

Share Improve this question asked Jul 10, 2011 at 18:29 jamesjames 2,6639 gold badges47 silver badges72 bronze badges 4
  • what result did u get with your example? did it work? – Ibu 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. – Brad 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 ? – phtrivier Commented Jul 10, 2011 at 18:37
  • Yeah silly I had spelled it wrong. – james Commented Jul 10, 2011 at 18:38
Add a ment  | 

1 Answer 1

Reset to default 6

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

to pass vars:

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

or yopu can visit the opeing window:

var variable = window.opener.variable;

本文标签: Javascript windowopen() passing argsStack Overflow