Click here to Skip to main content
15,891,473 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
How to pass Variable in window.open() in Javascript and Display it on another page
============================

Hi friends,
I want to Pass Variable in window.open and display it on another webpage.
I have Page1 and Page2 here

XML
<script type="text/javascript">
 function PopupSelectedDate()
    {
var viewportwidth = document.documentElement.clientWidth;
var viewportheight = document.documentElement.clientHeight;
var PassTime =
window.resizeBy(-200,0);
window.moveTo(0,0);
window.open("Page2.aspx", "mywindow","width=420, height=650, top=0, screenX=1000, screenY=1000");

    }
</script>


Please help
THANKS.
Posted

1 solution

C#
var myVariable = 'hello world';
window.open("page2.aspx?myvar=" + encodeURI(myVariable), "mywindow", "width=420, height=650, top=0, screenX=1000, screenY=1000");


on your page2.aspx get the variable using

Request.QueryString["myvar"]
 
Share this answer
 
Comments
Software Engineer 892 25-Mar-15 7:02am    
Many Thanks..its working now.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900