3

当我调用window.open父窗口时刷新。我还没有看到任何关于如何防止这种情况发生的信息。任何帮助,将不胜感激。

left = Number((screen.width/2)-(730/2)),
top = Number((screen.height/2)-(450/2));

var windowFeatures = 'location=0,menubar=0,resizable=0,scrollbars=0,status=0,width=700,height=500,top='+top+',left='+left;
    window.open('access-modal.html', '', windowFeatures);

win.moveTo(left, top);
4

2 回答 2

2

虽然编辑后我的帖子有问题。最终的解决方案是阻止默认操作。

$('.button').on('click', function(e) {

    e.preventDefault();

        left = Number((screen.width/2)-(730/2)),
        top = Number((screen.height/2)-(450/2));

        var windowFeatures = 'channelmode=0,directories=0,fullscreen=0,location=0,menubar=0,resizable=0,scrollbars=0,status=0,width=700,height=500,top='+top+',left='+left;
            win = window.open('access-modal.html?env=' + Data.currentOauth + '&url=' + Data.currentAddr, '', windowFeatures);

        win.moveTo(left, top);
        win.focus();

    }

});
于 2013-04-04T20:34:05.363 回答
1

我不确定这是否是您的编辑。我知道 win.moveTo(left, top) 上有错误。win 未定义..以下代码对我有用。

<script language="javascript" type="text/javascript">
            function windowOpen() {
                left = Number((screen.width / 2) - (730 / 2)),
                top = Number((screen.height / 2) - (450 / 2));

                var windowFeatures = 'location=0,menubar=0,resizable=0,scrollbars=0,status=0,width=700,height=500,top=' + top + ',left=' + left;
                var win = window.open('access-model.htm', '', windowFeatures);

                win.moveTo(left, top);
            }
        </script>
于 2013-04-04T19:10:16.377 回答