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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T05:51:56+00:00 2026-05-30T05:51:56+00:00

So I have a cool one for ya. I need to scan my html

  • 0

So I have a cool one for ya.

I need to scan my html document as it is rendering and replace every

href=""

with

onclick="window.location=''"

more than that, I need to carry the link from the href to the window.location.

For example, if I had:

href="http://www.google.com.au"

it would become:

onclick="window.location='http://www.google.com.au'"

and I need it to do this on every href in the document


I have no idea, but it needs to be in jQuery / javascript 😀

Thanks guys.

  • 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-05-30T05:51:57+00:00Added an answer on May 30, 2026 at 5:51 am

    You could try this:

    $('a').each(function() {
      var href = $(this).attr('href');
      $(this).attr('onclick', "window.location='" + href + "'")
             .removeAttr('href');
    });
    

    What are you trying to achieve with this? Chances are that there’s a more elegant way to achieve what you’re after.

    For example, it might be better to handle the event yourself in the JS. Replace the third line with:

    $(this).click(function() { window.location = href; })
    

    That could become very expensive though, so you might want to consider jQuery’s delegate events: http://api.jquery.com/delegate/

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

Sidebar

Related Questions

I have a cool snippet of code that works well, except one thing. The
I have recently focused on drawing some cool shapes in a HTML 5.0 canvas.
I have simple task where I need to check objects in one dictionary and
I'm creating this cool HTML Jeopardy game and I need a little coding help.
So I have some cool Image Processing algorithm. I have written it in OCaml.
I have a really cool website that allows people to upload images. Sometimes there
I have been building IMO a really cool RIA. But its now close to
If any of you have worked with a cool tool for viewing/querying the SQL
Does anyone have a suggestions for a superb cool image gallery that I can
I have a Property File like this: frame.server.dev=mark.is.cool frame.server.test=chris.is.cool frame.server.qa=mitch.is.cool frame.server.prod=cory.is.cool I need to

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.