【问题标题】:Javascript document.location new windowJavascript document.location 新窗口
【发布时间】:2013-12-27 09:17:22
【问题描述】:

我正在使用Simple Icons 制作一个自定义 Pinterest Pin It 按钮,并且我正在使用 Pinterest Widget Builder 给我的链接。在默认的 Pin It 按钮上,它会在一个全新的窗口中打开此链接。我查看了很多 SO 问题,但所有这些问题都在一个新的标签中打开。

我需要在新的窗口而不是标签中打开此链接。

HTML:

<div class="pinit" onclick='window.open("http://www.pinterest.com/pin/create/button/?url=http%3A%2F%2Flocalhost%3A8080%2FHowl%2FHome.html&media=http%3A%2F%2Fi.imgur.com%2FToZz7PB.png&description=Howl%3A%20Share%20Your%20Life")'><img src="http://raw.github.com/danleech/simpleicons/master/icons/pinterest/pinterest-64.png"></div>

CSS:

.pinit {
  background: #CB2027;
  width: 65px;
  border-radius: 10px;
  cursor: pointer;
}
.pinit:hover {
  background: #e41f11
}

JavaScript:

对于 JS,我使用了 Pinterest 链接:&lt;script type="text/javascript" async src="//assets.pinterest.com/js/pinit.js"&gt;&lt;/script&gt;

【问题讨论】:

    标签: javascript pinterest new-window


    【解决方案1】:

    试试这个

    <div class="pinit" onclick='window.open("http://www.pinterest.com/pin/create/button/?url=http%3A%2F%2Flocalhost%3A8080%2FHowl%2FHome.html&media=http%3A%2F%2Fi.imgur.com%2FToZz7PB.png&description=Howl%3A%20Share%20Your%20Life","Pin It","width=300,height=300,top=0,left100")'>
    

    为您的新窗口提供名称和属性。

    ,"Pin It","width=300,height=300,top=0,left100"
    

    【讨论】:

    • 我认为尺寸调整不起作用。高度看起来不是 300 像素。你需要里面的px吗?
    • 它的高度以 'px' 为单位,您可以尝试除 300 之外的其他数字,例如 width=600,height=500
    • 我一直在调整它的大小,它看起来仍然又瘦又高。
    • 你用的是什么尺寸的?
    • 没关系,我发现了问题。我用高度切换宽度,所以高度是 700,宽度是 300。这就是它又高又薄的原因
    猜你喜欢
    • 1970-01-01
    • 2012-06-20
    • 1970-01-01
    • 1970-01-01
    • 2013-02-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多