【问题标题】:Jquery .click hide function for closing windowJquery .click 关闭窗口的隐藏功能
【发布时间】:2014-08-13 22:56:09
【问题描述】:

我准备了我的页面片段来向您展示我的问题: a link

在底部显示名为 div "pomocnik" 的红色小窗口 在 Chrome 浏览器中单击“关闭”图标是否有效,但 IE 会为单击 DIV 内的文本做好准备 onclick="document.location.href('http://www.google.com') 所以它打开了新页面。

IE 已检测到 DIV 的 onclick,但 Chrome 检测到图像的详细信息。 我的想法是点击关闭按钮后关闭窗口。

$('#close').click(function() {
    //var g = document.getElementById("pomocnik");
    //g.style.display = 'none';
    $('#pomocnik').hide(2000);
    $('#konsul').click = null;
});

【问题讨论】:

    标签: javascript jquery html css internet-explorer


    【解决方案1】:

    我认为问题在于事件(单击关闭图像)首先调用隐藏您的 div 的事件处理程序,然后冒泡到包含 div 并为其启动默认操作(打开链接)。请尝试以下操作:

    $('#close').click(function(e) {
         //var g= document.getElementById("pomocnik");
         //g.style.display= 'none';
         e.stopPropagation(); //this will prevent the event from bubbling up to the containing div
         $('#pomocnik').hide(2000);
         //$('#konsul').click=null;
     });
    

    【讨论】:

    • 谢谢!我使用了你的提示,现在只关闭图标关闭窗口而不重定向。
    猜你喜欢
    • 2012-08-24
    • 2011-11-07
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-09-08
    • 2011-02-03
    • 2010-09-08
    相关资源
    最近更新 更多