【发布时间】:2013-04-24 03:34:42
【问题描述】:
我正在尝试将 href 加载到特定尺寸的弹出窗口中,该窗口也位于屏幕中心。
这是我的来源:
<li>
<a class="sprite_stumbleupon" href="http://www.stumbleupon.com/submit?url=http://www.your_web_page_url" target="_blank" onclick="return windowpop(545, 433)"></a>
</li>
这是我的 javascript:
function windowpop(url, width, height) {
var leftPosition, topPosition;
//Allow for borders.
leftPosition = (window.screen.width / 2) - ((width / 2) + 10);
//Allow for title and status bars.
topPosition = (window.screen.height / 2) - ((height / 2) + 50);
//Open the window.
window.open(url, "Window2", "status=no,height=" + height + ",width=" + width + ",resizable=yes,left=" + leftPosition + ",top=" + topPosition + ",screenX=" + leftPosition + ",screenY=" + topPosition + ",toolbar=no,menubar=no,scrollbars=no,location=no,directories=no");
}
这似乎在测试时返回 404 错误。我做错了什么?
非常感谢。
【问题讨论】:
-
您尚未将
url参数发送到windowpop函数。 -
function windowpop(url, width, height)该函数希望您返回一个 URL,但您只返回宽度和高度。 -
这可能有充分的理由关闭,但我发现它非常有用。我不知道 window.open 的任何这些额外参数。
标签: javascript html hyperlink popup modal-dialog