JavaScript中的弹出窗口

问题描述 投票:2回答:2

我在基于Blogger的website上使用自定义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>
javascript popup window blogger tumblr
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/上的演示代码


0
投票

使用javascript window.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");

© www.soinside.com 2019 - 2024. All rights reserved.