我在基于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+"&name="+strNewTitle+"' target='_new'><img src='http://platform.tumblr.com/v1/share_1.png'/></a>");
</script>
</div>
<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/上的演示代码
使用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");