Open the href mailto link in new tab / window

后端 未结 8 863
臣服心动
臣服心动 2020-12-05 09:56

I have an image which when click, I want to link to a mailto:

 
        

        
8条回答
  •  情深已故
    2020-12-05 10:42

    This answer is based on this answer Open the href mailto link in new tab / window.

    Right now, new browsers support some web mail interfaces (Like Gmail, Yahoo Mail, AoL, etc.).

    So we can simply open a new window (Support older browser, new browsers just will open a new tab) and add a fallback (In case of non-javascript user) using preventDefault and default link redirection.

    http://www.w3.org/TR/DOM-Level-2-Events/events.html#Events-flow-cancelation

    https://developer.mozilla.org/es/docs/DOM/event.preventDefault

    https://developer.mozilla.org/en-US/docs/Web/API/Window.open

    Like so:

    Send a e-mail

    http://jsfiddle.net/cNUNP/

    Credit to https://stackoverflow.com/a/9880404/1107020

    Guess that's all.

    Greetings, Marcos.

提交回复
热议问题