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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T23:47:04+00:00 2026-05-29T23:47:04+00:00

I have this HTML: <a href=# onclick=window.open(‘TrackPackage.asp?ID=4’, ”, ‘settings’);>Track Your Package »</a> Somebody on

  • 0

I have this HTML:

<a href="#" onclick="window.open('TrackPackage.asp?ID=4', '', 'settings');">Track Your Package »</a>

Somebody on this site was able to provide me with a script to prefix the URL with the domain http://www.example.com/ Here’s the script:

$(document).ready(function(){
$('a[onclick^="window.open(\'TrackPackage.asp"]').attr('onClick', $('a[onclick^="window.open(\'TrackPackage.asp"]').attr('onClick').replace("window.open('", "window.open('http://www.example.com/"));
});

However, I am having a little trouble with this:
The first issue is where there is multiple instances of the element. Here’s a fiddle: http://jsfiddle.net/VMmZx/
Instead of one anchor being signed with ID=4 and the other with ID=5 as intended, they’re both being signed with ID=4.
The idea is, each window.open function should be prefixed with http://www.example.com however, the remainder of the URL should remain intact…

The second problem I’m encountering is when the element does not exist on a page, the remainder of the jQuery fails…
Here’s another fiddle: http://jsfiddle.net/VPf32/
The <a> should get the class foo, but since the element does not exist on the page, the jQuery does not execute.
Since the JavaScript is being included in the HTML template of the ASP.NET server, this can create many problems.

I hope I’ve been clear and you can help me. 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-29T23:47:08+00:00Added an answer on May 29, 2026 at 11:47 pm

    Why are you doing the click even inline like that? I would just output the links like:

    <a href="/path/to/file.html" target="_blank">Link Text</a>
    

    And then:

    $('a[target=_blank]').click(function(){
       var prefix = 'http://domain.com';
       window.open(prefix + $(this).attr('href'));
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this HTML structure and want to convert it to an accordion. <div
I have this html... <select id=View name=View> <option value=1>With issue covers</option> <option value=0>No issue
I have this HTML code for radios: <input type='radio' name='a_27' value='Yes' id='a_27_0' /> <input
i have this html: <span class=price> $61.00 <span class=detailFreeShipping>With Free Shipping</span> </span> How to
I have this HTML dropdown: <form> <input type=text id=realtxt onkeyup=searchSel()> <select id=select name=basic-combo size=1>
I have this html: <div class=foo parent> <div class=child></div> </div> with some css: .foo{
I have this HTML structure (excerpt): <td> <select id=test1 class=pub_chooser> <option value=99>All Publications</option> <option
i have this html <ul> <li><form action=# name=formName></li> <li><input type=text name=someName /></li> <li><input type=text
I have this HTML in my page <div id='masterDIV'> <div id='divItemNumber'>23</div> <div id='divDesc'>This is
I have this html page which is very simple, it contains a text box

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.