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 8674747
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T19:46:52+00:00 2026-06-12T19:46:52+00:00

Due to restrictions, even though it is something i avoid altogether, in a certain

  • 0

Due to restrictions, even though it is something i avoid altogether, in a certain situation i have to use the javascript: syntax in a href attribute of an achor tag.

(EXPLANATION: In my CMS i use a rich text editor to allow the user to make changes to text elements, including links. In some cases specific javascript: calls are required and i banned onclick completely from the link editing features (to simplify the process for the user). However, as one of the links appears within a block that reacts to an onclick event, the thing double-fires)

Like this:

<a href="javascript:doSomething()"></a>

My problem is that this link is inside a container that already reacts to an onclick event. Therefore i wanted to pass the event object along to the doSomething() method, so that i could then use jQuery’s

event.stopPropagation()

method.

Unfortunately however, it seems that passing the event object along

<a href="javascript:doSomething(event)"></a>

does not seem to work at all. Safari won’t say anything while Firefox will report ReferenceError: event is not defined

I assume that this is the case because href=”” is not a script-initiating attribute (such as onclick). The problem is that in this situation i won’t be able to access the tag beyond what i already do.

Therefore i either need

1.) A way to pass the event object to the doSomething() function from within the href attribute

or

2.) A way to stop the event propagation right in that anchor (after its clicked) by other means.

Thank You for any constructive input!

  • 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-12T19:46:53+00:00Added an answer on June 12, 2026 at 7:46 pm

    You cannot stop event propagation from the href attribute because:

    1. When the href code executes, it is not an event. It just executes that code, similar to the “location hack”. Like entering javascript:doSomething() in the browser’s address bar.

    2. The href code executes after the events fire on the link — including bubbling.

      You can see that behavior in this jsFiddle. Note that mouseup, mousedown, and click all fire both for the link, and on the container when the link is clicked, before the href code executes.

    If there are event listeners that you want to block, you’ll have to find another way.


    But, if you can append javascript to the document you can block the href using preventDefault().

    For example:

    • jQuery, before version 1.7:

      $("#container a").bind ("mousedown mouseup click", function (e) {
          e.preventDefault();
      } );
      
    • jQuery 1.7 and later:

      $("#container a").on ("mousedown mouseup click", function (e) {
          e.preventDefault();
      } );
      

      or (better):

      $("#container").on ("mousedown mouseup click", "a", function (e) {
          e.preventDefault();
      } );
      

    You can see this last version live at jsFiddle.

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

Sidebar

Related Questions

Due to a sad situation I receive HTML like this: <p>Perform the following commands:
Due to an incident a few months prior, thousands of author_ids have been deleted
Due to a bug in my javascript click handling, multiple Location objects are posted
Due to a number of constraints that I won't get into, I have to
Due to Facebook api restrictions for iOS, I need to be able to send
Due to restrictions of editing some of my templates I really need your help
Due to some restrictions I am being forced to load a library written in
Due to work restrictions, I need to continue using Visual Studio 2010 for the
My project currently has a PieChart with a legend. Due to size restrictions I
I've asked the same question before for Flex, but due to some restrictions, I'm

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.