首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >带有固定链接的window.open onclick特定帖子

带有固定链接的window.open onclick特定帖子
EN

Stack Overflow用户
提问于 2015-10-15 19:29:03
回答 2查看 443关注 0票数 1

当我点击帖子时,它会打开一个随机的帖子,而不是我点击的帖子。

$postid = get_the_ID();在我代码的开头。

下面是我在post图像周围的<a>标记内的onlick=''中使用的函数

代码语言:javascript
复制
<script type="text/javascript">
    function wholeAd(){
        var permalink = '<?php echo get_permalink($postid); ?>';
        window.open(permalink, 'newwindow', 'width=900, height=650');
        return false;
    }
</script>
<div class="ad-box span3">
    <a class="ad-image" onclick='wholeAd()'>
EN

回答 2

Stack Overflow用户

发布于 2015-10-15 23:19:01

以下是解决方案:

你不需要创建一个函数

代码语言:javascript
复制
<a href="<?php the_permalink(); ?>" onclick="window.open(this.href,'newwindow', 'width=900, height=650');return false;">
票数 0
EN

Stack Overflow用户

发布于 2015-10-16 15:38:44

对于弹出窗口,可以使用如下所示的内容

代码语言:javascript
复制
"<a href='javascript:OpenPopUpPageWithTitle(&#39;"+oListItem.get_item('Url').get_url()+"&#39;, &#39;NotificationCallback&#39;, "+oListItem.get_item('Width')+", "+oListItem.get_item('Height')+",&#39;" + oListItem.get_item('Title') + "&#39;);'>&nbsp;" + oListItem.get_item('Title') + "</a>"

对于新窗口,您可以使用如下所示的内容

代码语言:javascript
复制
<a target='_blank' href='url' style='styles'>Title</a>

希望这会有帮助,如果它解决了你的问题,请将它标记为答案

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/33147355

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档