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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T10:24:47+00:00 2026-06-10T10:24:47+00:00

I am modifying an ancient table which has inline JavaScript in the form of

  • 0

I am modifying an ancient table which has inline JavaScript in the form of <a href="javascript:<lots of shit>">. The inline JavaScript works, but it would take months to rewrite it so that it fits my assignment, which is when an outer element is clicked the inline JavaScript should be executed.

I’m sorry if I’m not making any sense, but I have been as thoughtful as to provide a fiddle. (The table aspect shouldn’t matter.) TL;DR: when I click one of the colored div‘s I would like its inner alert() to execute and how do I do that?

Edit. Also, the link is actually hidden!

Edit #2. And, as for now, none of the HTML should be tampered with. Only jQuery/JavaScript.

Edit #3. I’ve updated the script to work with my table. The inner <span> is now not needed, I can select the <a> directly. Now I would just like to know if I’m using stopPropagation() correctly?

Code:

$(function () {
    $('table.result-v2 tr.view').bind('click', function () {
        var $this = $(this),
            $next = $this.next();

        if ($next.attr('class') == 'detail') {
            var $buttons = $this.find('td.buttons'),
                $link = null;

            if ($next.css('display') == 'none') {
                $link = $buttons.find('a.show-link');
            } else {
                $link = $buttons.find('a.hide-link');
            }

            if ($link != null) {
                eval($link.attr('href')); // evaluate found link
                $link.bind('click', function (event) {
                    event.stopPropagation(); // is this needed when the link never can be clicked (it's hidden)?
                });
            }
        }
    });
});
  • 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-10T10:24:48+00:00Added an answer on June 10, 2026 at 10:24 am

    Here is a quick hack that made your code work. And just to note that this is totally not how it should be done!

    http://jsfiddle.net/2QaUX/1/

    Instead of triggering a click, evaluate the inline script inside the href attribute:

    Old:

    $(function () {
        $('.foo').bind('click', function () {
            $(this).find('.bar').parent().trigger('click');
        });
    });​
    

    New:

    $(function () {
        $('.foo').bind('click', function () {
            eval($(this).find('.bar').parent().attr('href'));
        });
        $('.bar').parent().bind('click', function (event) {
            event.stopPropagation(); 
        });
    });​
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

(Modifying the question)I have a windows form app in C# which calls into some
Obviously modifying it would be out of the question. But you would think just
Modifying CKEditor 3.6.2 is not easy, but I tried hard . One problem that
Modifying working form with one spot per order to multiple spots per order I
I am working on modifying a view and I'm stuck. My user has an
I am modifying an existing report which is setup to let you view statistics
I am modifying my login/registration form via login.phtml and have a problem with the
Im modifying a theme in wordpress and would like to have the possibility to
I am modifying a SQL table through C# code and I need to drop
I'm currently modifying a class that has 9 different constructors. Now overall I believe

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.