Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8038125
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T03:07:58+00:00 2026-06-05T03:07:58+00:00

In Javascript code, I would like to programmatically cause the browser to follow a

  • 0

In Javascript code, I would like to programmatically cause the browser to follow a link that’s on my page. Simple case:

<a id="foo" href="mailto:somebody@example.com">something</a>

function goToBar() {
   $('#foo').trigger('follow');
}

This is hypothetical as it doesn’t actually work. And no, triggering click doesn’t do it.

I am aware of window.location and window.open but these differ from native link-following in some ways that matter to me: a) in the presence of a <base /> element, and b) in the case of mailto URLs. The latter in particular is significant. In Firefox at least, calling window.location.href = "mailto:somebody@example.com" causes the window’s unload handlers to fire, whereas simply clicking a mailto link does not, as far as I can tell.

I’m looking for a way to trigger the browser’s default handling of links, from Javascript code.

Does such a mechanism exist? Toolkit-specific answers also welcome (especially for Gecko).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T03:07:59+00:00Added an answer on June 5, 2026 at 3:07 am

    As far as I know, window.location does exactly what you are looking for, triggering the browser’s default link clicking behavior.

    Some browsers notice the protocol before any events are fired or the actual href is changed.

    window.location = "mailto:somebody@example.com";
    

    Trying the fiddle demo mentioned below I get the following results:

    • Chromium: fires onbeforeunload with the button and link
    • Firefox fires onbeforeunload only for the button
    • Safari: never fires onbeforeunload
    • Opera: same as Safari

    So a good way to prevent the unload event from being fired is by returning false in beforeunload.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like a simple JavaScript code that will allow me to hide a
I would like to create a simple web statistics javascript code ( analytics )
I would like to keep normal html/javascript code on GAE server, but during page
I would like to write JavaScript code that flattens the DOM of an arbitrary
I have a javascript code that access a sqlite3 database. I would like to
This is some simple JavaScript code I would like to implement, butit does not
I would like to write a JavaScript function that validates a zip code, by
I would like to have some Javascript code running in a web browser write
I'm new to JavaScript and would like some constructive criticism regarding a code snippet.
I would like to include the Google Analytics Javascript code in the head element

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.