首页 > 解决方案 > PHP:使用 onclick 在新窗口(不是新选项卡)中打开 href

问题描述

我试图在 php 中包含一个 onclick javascript,但我无法让它正常工作。该链接将在浏览器的新选项卡中打开,但不会在 Javascript 所做的新窗口中打开。

我相信我已经正确地转义了单引号,这就是我认为的问题所在。

请参阅下面的 php 代码。

$image = sprintf( '<div class="wpcp-slide-image"><a onclick="window.open(this.href, \'left=20,top=20,resizable=0\'); return false;" href="'.$custom_notification_data.'">%1$s</a></div>', $post_thumb, get_the_permalink() );

标签: phpwindownew-operator

解决方案


推荐阅读