2

我在基于 Blogger 的网站上使用自定义 Tumblr 共享按钮,我希望共享屏幕在弹出窗口中打开。现在它在一个新选项卡中打开。

有人可以告诉我如何做到这一点吗?

<div class='tumblr-button'>
<script>
var strPostUrl = "<data:post.url/>";
var strPostTitle = '<data:post.title/>';
var strNewUrl = strPostUrl.replace("http://","");
var strNewTitle = strPostTitle.replace(/"/g, '"');
document.write("<a href='http://www.tumblr.com/share/link?url="+strNewUrl+"&amp;name="+strNewTitle+"' target='_new'><img src='http://platform.tumblr.com/v1/share_1.png'/></a>");
</script>
</div>
4

2 回答 2

1
   <div class='tumblr-button'>
    <script>
    var strPostUrl = "http://google.com";
    var strPostTitle = 'Google';
    var strNewUrl = strPostUrl.replace("http://","");
    var strNewTitle = strPostTitle.replace(/"/g, '"');

    </script>
    <a href='javascript:void(0);' id='tumblr'><img src='http://platform.tumblr.com/v1/share_1.png'/></a>
</div>
    <script type="text/javascript">
    jQuery(document).ready(function(){
        jQuery('#tumblr').click(function(){
         var width  = 775,
            height = 500,
            left   = ($(window).width()  - width)  / 2,
            top    = ($(window).height() - height) / 2,        
            opts   = 'status=1' +
            ',width='  + width  +
            ',height=' + height +
            ',top='    + top    +
             ',left='   + left;
    var url = "http://www.tumblr.com/share/link?url="+strNewUrl+"&name="+strNewTitle;
    window.open(url , 'tumblr', opts);
    });
   });
    </script>

检查http://jsfiddle.net/gzMXd/上的演示代码

于 2013-02-19T10:29:24.160 回答
0

使用javascriptwindow.open()函数

$('#buttonID').click(function() {
  myWindow=window.open('','','width=200,height=100');  
  myWindow.document.write("<p>This is 'myWindow'</p>");  
  myWindow.focus();  
});

句法:

window.open (URL, windowName[, windowFeatures])

例如。window.open ("http://jsc.simfatic-solutions.com", "mywindow","status=1,toolbar=1");

于 2013-02-19T10:23:21.753 回答