简体   繁体   中英

How to pass parameter in javascript's url?

I have a javascript function to open the new window when we click the link but i want to pass the value "id" to another page. How can I add the value to url> Following is the code...

 <SCRIPT language="JavaScript1.2">
    function openoldgurantorwindow()
      {
     window.open("enter code heregurrantor/old",
    "mywindow","location=1,status=1,scrollbars=1,width=700,height=700");
    }
    </SCRIPT>
    <a href="javascript: openoldgurantorwindow()">Click to view old Guarantors</a> 

Thank you in advance.

You can pass id or any other parameter as query params like shown below:

function openoldgurantorwindow(id) {
    window.open("http://example.com?id=" + id,
            "mywindow", "location=1,status=1,scrollbars=1,width=700,height=700");
}

And can be retrieved at next page in PHP code in $_GET variable.

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