小编use*_*885的帖子

使用Javascript在弹出窗口中打开链接

我正在尝试将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>
Run Code Online (Sandbox Code Playgroud)

这是我的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 + …
Run Code Online (Sandbox Code Playgroud)

html javascript modal-dialog popup hyperlink

11
推荐指数
1
解决办法
7万
查看次数

标签 统计

html ×1

hyperlink ×1

javascript ×1

modal-dialog ×1

popup ×1