问题
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.
回答1:
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;
来源:https://stackoverflow.com/questions/6643036/javascript-window-open-passing-args