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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T19:50:43+00:00 2026-05-29T19:50:43+00:00

I have <a> s with onclick events: <a href=# onclick=window.open(‘TrackPackage.asp’, ”, ‘location=1,menubar=1,scrollbars=1,status=1,resizable=1,width=635,height=460’); return false;

  • 0

I have <a>s with onclick events:

<a href="#" onclick="window.open('TrackPackage.asp', '', 'location=1,menubar=1,scrollbars=1,status=1,resizable=1,width=635,height=460'); return false;" class="nounderline">Track Your Package »</a>

How can I prepend those onclick events with http://www.example.com so that the result will be:

<a href="#" onclick="window.open('http://www.example.com/TrackPackage.asp', '', 'location=1,menubar=1,scrollbars=1,status=1,resizable=1,width=635,height=460'); return false;" class="nounderline">Track Your Package »</a>

It has to be compatible with jQuery 1.4.2

Somebody else, had mentioned something like this, but I can’t get it to work in 1.4.2:

var link = $("a"); // I don't have enough info to tell you how to precisely get this instance
var originalOnClick = link.attr("onclick");
var part1 = "window.open('"; // this is always the same, right?
var part2 = originalOnClick.substr(part1.length); // the remainder, beginning with TrackPackage.asp
var newOnClick = part1 + "http://www.example.com/" + part2;

link.attr("onclick", newOnClick);

Thanks.

  • 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-29T19:50:45+00:00Added an answer on May 29, 2026 at 7:50 pm

    I don’t think window.open() is a good idea here. It will get blocked by most popup blockers and if you’re using jQuery you shouldn’t be using the inline onclick event anyway.
    What you’re trying to do can probably be achieved with a simple anchor link:

    <a href="trackPackage.asp" target="_blank"></a>
    

    And then you can do something like this:

    var prependUrl = function($link, url) {
        var oldUrl = $link.attr('href'),
            newUrl = url + oldUrl;
        $link.attr('href', newUrl);
    }
    
    prependUrl($('#yourLink'), 'http://www.example.com/');
    

    EDIT:

    If you don’t have control over the html and you need to do it like that then use replace() on the onClick attribute like:

    $('a').attr('onClick', $('a').attr('onClick').replace('window.open(\'', 'window.open(\'http://example.com/'));
    

    example: http://jsfiddle.net/elclanrs/AH4As/

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

Sidebar

Related Questions

I have an input button that calls a window.location.href event, and also want to
I have an gridview that I am adding onclick events to a checkbox column
rbnResubmission.Items.FindByValue(Yes).Attributes.Add(onclick, getCheckedRadioFieldResubmission(this)); rbnResubmission.Items.FindByValue(No).Attributes.Add(onclick, getCheckedRadioFieldResubmission(this)); So I have these click events for showing rows in
On Window 's load, every DD element inside Quote_App should have an onCLick event
I have an asp button with no onclick event but only onclientclick. This call
I have a onclick event for a href , but if a define a
I have a onclick event that is like: public void OnMyButton_Click(object sender, EventArgs e)
I have a div which I have attached an onclick event to. in this
I have a gridview control that has on onclick event bound to every cell.
I have a strange problem where an onclick event on an input image is

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.