【发布时间】:2015-04-13 08:17:20
【问题描述】:
在我的 wordpress 博客主题的一部分中,帖子的社交媒体共享是动态生成的。我怎样才能让它在新窗口中打开?
我的一个静态 HTML 共享 <a> 在新窗口中打开的标签:
<a title='Share on Facebook' href='#' onclick="window.open('https://www.facebook.com/sharer/sharer.php?u=staging.example.org','mywindow','width=600,height=600');">
Share
</a>
我也想做的动态 PHP 示例:
if(themeple_post_meta(get_the_ID(), 'twitter_link') != '')
$output .= '<li class="twitter">
<a href="'.themeple_post_meta(get_the_ID(), 'twitter_link').'" title="Twitter"><i class="moon-twitter"></i></a>
</li>';
【问题讨论】:
-
将
_target="blank"属性添加到您的a标记(如果我正确理解您的声明。) -
@mudasobwa 冒着只能在新标签页中打开的风险。我正在尝试确保链接将在新窗口中打开(就像
window.open所做的那样)。
标签: php wordpress share social-media new-window