简体   繁体   中英

Operations with window.open

I have a javascript code that opens a page by doing the following: location.href("newPage.cfm?param1=xxx&param2=yyy");

The "newPage" must return to the previous, passgin some parameters, like this:

location.href("prevPage.cfm?param1=www&param2=kkk") .

Now, I want to do the same thing, to open the newPage, using:

window.open

My question is: how can I return to the previous page, closing the new one ( window.close ), but passing the new parameters?

You can access the previous window using window.opener . http://www.w3schools.com/jsref/prop_win_opener.asp

So you simply need to change your code to:

window.opener.location.href("prevPage.cfm?param1=www&param2=kkk");
window.close();

this is in your opened window.

you also use this.

<script language="javascript">
         window.opener.location = "prevPage.cfm?param1=www&param2=kkk";
         window.close();
</script>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM