Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/474.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何在不使用iframe和标记的情况下显示弹出式联系人表单_Javascript_Jquery_Html_Iframe - Fatal编程技术网

Javascript 如何在不使用iframe和标记的情况下显示弹出式联系人表单

Javascript 如何在不使用iframe和标记的情况下显示弹出式联系人表单,javascript,jquery,html,iframe,Javascript,Jquery,Html,Iframe,这是我的html代码 <!doctype html> <html lang="en"> <head> <meta charset="utf-8"> <title>Modal Popup</title> <body> <a href="https://dev88.wufoo.com/forms/ze7xusq0j2tum9/" onclick="win

这是我的html代码

    <!doctype html>
    <html lang="en">
    <head>
    <meta charset="utf-8">
    <title>Modal Popup</title>

    <body>
    <a href="https://dev88.wufoo.com/forms/ze7xusq0j2tum9/" onclick="window.open(this.href,  null, 'height=823, width=680, toolbar=0, location=0, status=1, scrollbars=1, resizable=1'); return false">Please fill out my form.</a>

    </body>
    </html>

模态弹出窗口
我想知道,如何将此联系我们表单显示为弹出窗口,并在其外部单击以将其关闭。 这是我的错误代码。你能帮我吗

为了满足“点击外部,它应该关闭”的要求,您需要一些JS来跟踪窗口的打开和关闭时间。当您从父页面打开窗口时,它将打开一个弹出窗口,如果您再次单击父页面,而窗口仍然打开,弹出窗口将关闭

<script>
    var test = document.getElementById('test');
    var win = null;

    test.addEventListener('click', function(e) {
        e.preventDefault();
        e.stopPropagation();

        win = window.open(test.href,  null, 'height=823, width=680, toolbar=0, location=0, status=1, scrollbars=1, resizable=1');
        return false;
    });

    window.addEventListener('click', function(e) {
        if(win != null) {
            win.close();
            win = null;
        }
    });
</script>

...

<a href="https://dev88.wufoo.com/forms/ze7xusq0j2tum9/" id="test">Please fill out my form.</a>

var test=document.getElementById('test');
var-win=null;
test.addEventListener('click',函数(e){
e、 预防默认值();
e、 停止传播();
win=window.open(test.href,null,'height=823,width=680,toolbar=0,location=0,status=1,scrollbars=1,resizable=1');
返回false;
});
window.addEventListener('click',函数(e){
if(win!=null){
win.close();
win=null;
}
});
...

工作演示:

问题在于,当您在中单击时,您将转到链接而不是打开的弹出窗口,对吗?不,我需要单击链接时,它将显示弹出窗口形式是,但在您的示例中,不是显示弹出窗口。。。你去这个?检查我的答案,但我不确定它是否对你有帮助。我不明白你的问题:(我可以知道这是什么吗?)只是一个“链接”单击并打开jQuery对话框。根据您的描述,您现有的代码将无法满足您的要求。您是否只需要一个简单的弹出窗口?我的代码需要添加一些脚本,因此根据我的测试,只有它将显示为弹出窗口。您的代码似乎正在弹出窗口,这不是您想要的吗?