Blogger上的Tumblr自定义分享按钮 - 打开弹出窗口
Tumblr custom share button on Blogger - open pop up window
我正在尝试在我的帖子下创建一个从博主到tumblr的分享按钮。使用高级选项,我几乎实现了我的目标,但代码没有打开一个新窗口,而是使用与共享帖子相同的选项卡,并在最后一秒应该关闭选项卡时挂起。
如何更改代码以打开一个漂亮的弹出窗口?
<!-- Put this tag wherever you want your button to appear -->
<span id="tumblr_button_abc123"></span>
<!-- Set these variables wherever convenient -->
<script type="text/javascript">
var tumblr_link_url = "http://www.example.com/permalink/my-article";
var tumblr_link_name = "My Awesome Article";
var tumblr_link_description = "Lorem ipsum...";
</script>
<!-- Put this code at the bottom of your page -->
<script type="text/javascript">
var tumblr_button = document.createElement("a");
tumblr_button.setAttribute("href", "http://www.tumblr.com/share/link?url=" + encodeURIComponent(tumblr_link_url) + "&name=" + encodeURIComponent(tumblr_link_name) + "&description=" + encodeURIComponent(tumblr_link_description));
tumblr_button.setAttribute("title", "Share on Tumblr");
tumblr_button.setAttribute("style", "display:inline-block; text-indent:-9999px; overflow:hidden; width:20px; height:20px; background:url('http://platform.tumblr.com/v1/share_4.png') top left no-repeat transparent;");
tumblr_button.innerHTML = "Share on Tumblr";
document.getElementById("tumblr_button_abc123").appendChild(tumblr_button);
</script>
您可以更改链接目标:
tumblr_button.setAttribute("target", "_blank");
但是,如果您想控制尺寸(并保证它不会在新选项卡中呈现),则需要执行更多操作:
tumblr_button.setAttribute("onclick", "window.open(this.href, 'mywin','left=20,top=20,width=500,height=500,toolbar=1,resizable=0'); return false;");
后一种解决方案是从这里借来的,但您可能还想查看此IE兼容性问题。
相关文章:
- 创建一个类似链接的按钮,并通过Javascript函数打开一个新的弹出窗口
- 如何调整信息窗口的大小并点击按钮?+更改信息窗口的内容
- 按下一个HTML按钮,该按钮使用一个功能在同一个新窗口中打开URL
- 如何在单击“提交”按钮时为“新建”窗口编写JavaScript,用“确定”和“取消”显示注册信息
- 如何在Ol3弹出窗口中添加用javascript创建的按钮上的点击事件
- 在窗口中单击按钮完成之前,光标不会停止.请继续卸载
- 如何隐藏谷歌地图Api 3中InfoBox窗口中的关闭(x)按钮
- 单击按钮时的窗口属性
- 单击谷歌地图信息窗口按钮
- Angular.js谷歌地图信息窗口按钮点击没有传递值
- 谷歌地图信息窗口按钮未显示
- 引导:弹出窗口按钮链接不工作
- 引导:点击弹出窗口按钮
- 使用angular验证引导模式窗口按钮点击时的输入字段
- 关闭当前的弹出窗口按钮点击在顶点使用salesforce
- 关闭窗口按钮- javascript
- 使用iFrame's OnSubmit函数为父窗口's按钮's OnClick事件
- jQuery UI模态弹出窗口-按钮点击
- jQuery UI模态弹出窗口按钮点击
- 以编程方式弹出“打开”窗口.按钮不工作在我的mapbox.js地图我已经创建