弹出窗体居中

时间:2012-11-13 06:02:30

标签: javascript html

说实话,我根本不懂JavaScript。我一直在通过看别人来搞清楚事情,但这次不是!我希望我的一个表单以提交为中心弹出。到目前为止,我已经将它弹出并保留表单数据,但我似乎无法将其置于中心位置!以下是我正在使用的一些代码:

如果有人可以向我解释这将是伟大的。我的表单操作看起来有点疯狂使用document.getElementByID('Name')。vaule加上电子邮件等等但表单字段ID与操作不匹配但IT仍然无效。我对此没有任何线索或为什么它实际上仍然有效。http://www.computerbytez.com/develop.html表单在行动!

形式:

<form action="https://computerbytez.com/InstantChat/Standard/logmein.html?Name=' + document.getElementById('Name').value + '&amp;Email=' + document.getElementById('Name').value, '', 'toolbar=no, status=no, menubar=no, titlebar=no, location=no, scrollbars=no, resizable=no, height=500, width=400'" id="lmiform">
            <div class="form-field">
        <label class="cm-required   " for="elm_7">Name</label> <input class="input-text" id="elm_7" name="name" size="50" style="width: 100%; max-width: 372px;" type="text"/></div>
<div class="buttons-container">
        <span class="button-submit button-wrap-left"><span class="button-submit button-wrap-right"><input type="submit" value="Connect To Technician" /></span></span></div>

表单JavaScript:

$(document).ready(function() {
    $('#lmiform').submit(function() {
 window.open('', 'formpopup', 'width=620,height=480,scrollbars=no,resizable=no,top=200,left=200');
        this.target = 'formpopup';
    });
});

我也一直在搞乱这个(弹出中心的链接),我一直试图将两者合并而没有运气:

<script>
function PopupCenter(pageURL, title,w,h) {
var left = (screen.width/2)-(w/2);
var top = (screen.height/2)-(h/2);
var targetWin = window.open (pageURL, title, 'toolbar=no, location=no, directories=no, status=no, menubar=no, scrollbars=no, resizable=no, copyhistory=no, width='+w+', height='+h+', top='+top+', left='+left);
} 
</script>

<a href="javascript:void(0);" onclick="PopupCenter('example.html', 'myPop1',620,470);"><img alt="" class="LMIpic" src="live_help_online.gif" /> </a>

非常感谢任何帮助。感谢

1 个答案:

答案 0 :(得分:4)

我访问过您的网站,点击图片时弹出窗口显示居中并且很好。 代码看起来很好。尝试清除浏览器缓存。

编辑:

    $(document).ready(function() {
        $('#lmiform').submit(function() {
            var left = (screen.width/2)-(620/2);
            var top = (screen.height/2)-(480/2);
            window.open('', 'formpopup', 'width=620,height=480,scrollbars=no,resizable=no,top='+top+',left='+left);
            this.target = 'formpopup';
        });
    });
相关问题