我正在尝试使用 javascript 中的 window.open 方法创建一个弹出窗口,它在没有任何动态变量传递的情况下工作正常,但我不知道如何在函数内部传递 php 变量以使其在另一个函数中起作用窗口。
这是我到目前为止尝试过的:
<?php
if(isset($d->retweeted_status->id_str)){
$tweetId = $d->retweeted_status->id_str;
} else{
$tweetId = $d->id_str;
}
$myUrl = "retweetDetails.php?id=".$tweetId;
<?
<a href="javascript:;" onclick="window.open('retweetDetails.php', 'my_new_window','width=625, height=400');" class="btn btn-default twitter_button_retweets"><?php echo $d->retweet_count; ?> Retweets </a>
我想将此 $myUrl
变量作为 url 参数传递,该参数将反射(reflect)在弹出窗口中。
谢谢
最佳答案
<a href="javascript:;" onclick="window.open('<?php echo $myUrl; ?>', 'my_new_window','width=625, height=400');" class="btn btn-default twitter_button_retweets"><?php echo $d->retweet_count; ?> Retweets </a>
关于javascript - 如何在 window.open 方法中将动态 PHP 变量作为参数传递,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34410237/