mailto link (in chrome) is triggering [removed] - can i prevent this?

后端 未结 7 1324
鱼传尺愫
鱼传尺愫 2021-02-18 19:09

Possibly related to How to open mailto link in Chrome with Window.open without creating a new tab?

Hi all. I have a form page where i\'ve put a window.onbeforeunload co

7条回答
  •  青春惊慌失措
    2021-02-18 19:40

    Add a flag and see if it is flipped, set the flag on the link click.

    var ignore = false
    window.onbeforeunload = function() {
        if (changed && !ignore) {
            return "You have unsaved changes.  Do you really want to leave this page without saving?";
        } else {
            ignore = false;
        }
    }
    

    And the link

    Report a problem
    

    It would be better to add the onclick with JavaScript code.

提交回复
热议问题