简体   繁体   English

新窗口中的弹出窗口将在新选项卡中打开

[英]Popup in new window opens in new tab instead

I have a calendar created with php. 我有一个用PHP创建的日历。 In this calendar I have load_id's listed by date. 在这个日历中,我按日期列出了load_id。 I made a popup to show more data for each load. 我做了一个弹出窗口,显示每个负载的更多数据。 I want it to show as a popup not in a new tab. 我希望它显示为不在新标签中的弹出窗口。 I have tried doing it as a function but as I don't know javascript I could not figure out how to pass the load_id to the url. 我已经尝试将其作为一个函数,但由于我不知道javascript我无法弄清楚如何将load_id传递给url。 If I replace "this.href" with the url in a function it works like a charm. 如果我将“this.href”替换为函数中的url,它就像魅力一样。 But again I don't know how to pass the load id as a variable so that won't work for me. 但是我再次不知道如何将load id作为变量传递,因此对我来说不起作用。 If someone could point out where I made my mistake passing the variable I would be much obliged! 如果有人能指出我错误传递变量的地方,我会非常感激!

This is what I have now: 这就是我现在拥有的:

echo "<span class='load_shipped'>
<a href='cal_popup.php?load_id=".$load_id."'
onclick='window.open(this.href, '_blank','left=100,top=100,width=500,height=500,toolbar=1,resizable=0');'>
".$load_id."
</a>
<br>
</span>\n";

I tried this as well to no avail: 我试过这个也无济于事:

echo "<span class='load_shipped'>
<a onclick='popup(".$load_id.");'>".$load_id."</a><br>
</span>\n";

Javascript: 使用Javascript:

<script>
    function popup(id){
        window.open('cal_popup.php?load_id=id', '_blank','left=100, top=100,width=500,height=500,toolbar=1,resizable=0');
    }
</script>

All this did though was pass 'id' instead of the real load_id. 所有这些都是通过'id'而不是真正的load_id。

Seems like you're having trouble because you're using the same quotes to wrap the attribute onclick and to define the parameters of the window.open call. 看起来你遇到了麻烦,因为你使用相同的引号来包装属性onclick并定义window.open调用的参数。 Try using double quotes on the attribute. 尝试在属性上使用双引号。 You'll also need to return false; 你还需要return false; at the end of the onclick to prevent the link working as normal. onclick结束时,以防止链接正常工作。

echo "<span class='load_shipped'>
    <a href='cal_popup.php?load_id=".$load_id."'
    onclick=\"window.open(this.href, '_blank','left=100,top=100,width=500,height=500,toolbar=1,resizable=0');return false;\">
    ".$load_id."
    </a>
    <br>
</span>\n";

In your last example where you have the function popup - please note that you need to concatenate the id variable into the string like 'cal_popup.php?load_id=' + id . 在上一个有popup函数的例子中 - 请注意你需要将id变量连接到字符串中,如'cal_popup.php?load_id=' + id

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Chrome:window.open会打开新标签而不是新的弹出窗口 - Chrome: window.open opens new tab instead of new popup window 带有'noopener'的Window.open打开一个新窗口而不是一个新选项卡 - Window.open with 'noopener' opens a new window instead of a new tab window.open打开一个新选项卡而不是一个新窗口(在chrome中) - window.open opens a new tab instead of a new window (in chrome) 使用target =“_ blank”的表单提交会在ajax请求之后打开一个弹出窗口,而不是新选项卡 - Form submit with target=“_blank” opens a popup window after ajax request instead new tab window.open在打开操作表后打开弹出窗口,而不是新选项卡 - window.open opens popup instead of new tab after opening action sheet window.open在新标签页而不是弹出窗口中打开页面 - window.open open the page in a new tab instead of in popup window 打开弹出窗口 window 而不是美元托管控件中的新选项卡/窗口 - Open popup window instead of new tab/window in USD hosted control window.open 在新的 window 中打开,而不是使用“nofollow/赞助”时的新标签 - window.open opens in new window instead of new tab when using "nofollow/sponsored" Selenium IE驱动程序将打开新窗口,而不是window.open()上的新选项卡 - Selenium IE Driver opens new window instead of a new tab on window.open() window.open(url,windowname,opts)在新选项卡中打开,而不是在Firefox中打开新窗口 - window.open(url, windowname, opts) opens in new tab instead of new window in Firefox
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM