【问题标题】:how can i clicked a link in diffrent frames without firing onbeforeunload in the other frames如何在不同帧中单击链接而不在其他帧中触发 onbeforeunload
【发布时间】:2009-09-15 02:41:10
【问题描述】:

我有一个网页,其中包含两个框架,例如左侧的菜单和右侧的内容。在内容框架中,我使用了 onbeforeunload 函数,当用户没有填写所有信息时,该函数会在用户想要关闭该网页时触发。问题是,当我点击菜单的框架时,onbeforeunload 会触发。有没有办法解决这个问题? 对不起我的英语**谢谢

【问题讨论】:

    标签: frames onbeforeunload


    【解决方案1】:

    您可以连接链接的 onclick 并阻止事件冒泡到窗口。这将阻止链接调用 onunload,因为框架不会卸载。然后,您可以在没有锚点 onclick 事件的情况下做您想做的事情。

    我认为这样做可以:

    function handleClickEvent (event) {  
        event.stopPropagation();
        // do your thing there.
    }
    

    更多关于停止传播的信息:MDC Event Propagation

    【讨论】:

      猜你喜欢
      • 2014-03-12
      • 1970-01-01
      • 2017-12-24
      • 2010-12-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多