如何通过href将值传递给新的弹出窗口

I want have a variable which i want to pass from parent page to popup window.

Trying below but not getting required output on popup window.

Parent page:

<a href=cancellation_policy.php?d=",urlencode($vendor_id),"  onclick="window.open('cancellation_policy.php','newwindow', 'width=700, height=450'); return false; "><?php echo "<h10>(Cancellation policy)</h10>";}?></a>

On popup window:

<?php echo $vendor_id = $_GET['$d']; ?>

During your JavaScript call to the Popub, you use the cancellation_policy.php without any parameters. So echo $vendor_id = $_GET['$d']; will not echo anything. Also you called your parameter in the URL 'd' and not '$d'.

You either have the possibility to add them to the JavaScript call:

window.open('cancellation_policy.php?d=[...]'...

or by having a JavaScript function that uses the href attribute of the a tag to build a complete URL and then use window.open(...). The first Idea is probably the faster solution.

Edit: For better explanation: The window.open method does not use the href attribute of your a-element. So the there configured parameter 'd' will not be used here.

You can call a function in any tag and have the function open the window. Something like this:

<script type="text/javascript">
function test() {
  window.open('cancellation_policy.php?d=' + urlencode($vendor_id),'newwindow', 'width=700, height=450'); 
}
</script>

<a onclick="javascript:test()"><?php echo "<h10>(Cancellation policy)</h10>";}?></a>

You can have the href as you need it then such onclick to make the link open in new window:

<a href=".." onclick="window.open(this.href, 'newwindow', 'width=700,height=450'); return false; ">

The this.href will simply take whatever you have in the href attribute, no need to repeat it.