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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T02:06:59+00:00 2026-05-16T02:06:59+00:00

how can I replace all url’s in a page with different URL using jquery

  • 0

how can I replace all url’s in a page with different URL using jquery ?
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-16T02:07:00+00:00Added an answer on May 16, 2026 at 2:07 am

    Found this:

    //Create an object of all links
    var links = $('a');
    //Parse each item in links object
    for (var a in links){
    //This will allow the for iteration to give the actual link objects that are
    //referred to with numeric indexes and not objects that jQuery appends
    //Object 'a' should be a number
        if(a == parseInt(a)){
            //Variable b is now the object that is links[a];
            var b = links[a];
            //Variable c is now variable b cast to jQuery so I can use built in jQuery functions
            var c = $(b);
            //Variable temp now contains the href of that link
            var temp = c.attr('href');
            //This should filter out any anchors in the page or any links without an href
            if(temp != undefined){
                //This checks to see if they are inline links, mailto link, OR absolute link
                //This isn't perfect in the case that your link was 'mailsomething.php' or any non http link (ftp or other protocol)
                //The correct scenario here is to use regex but I didn't have the patience
                //or time to do so, so I didn't plus I knew my links didn't apply to these caveats
                var test = temp.substring(0,4);
                if(test != 'mail' && test != 'http' && test != '#'){
                    //Now we prepend the abosulte url with the proper and add the relative file location
                    c.attr('href','http://differentsubdomain.domain.com/'+temp);
                }
            }
        }
    }
    

    on this page:

    Rewrite all links on a page…

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

Sidebar

Related Questions

All, I'm using the following jQuery plugin: https://github.com/blueimp/jQuery-File-Upload You can see that in the
location.href location.replace document.URL As seen from other similar questions, can we consolidate all such
How can I replace all the occurrences of the $keyword within a string without
How can I replace all line-endings in big file (>100MB)? I have tried to
How can I replace all numbers and special chars with empty spaces in a
How can I replace all the with the raw string \ in a string
Is there a lazy way I can quickly replace all instances of a word
How do I use the sha512 function for PHP? Can I replace all my
data1/data2/data3 How can I find and replace all cells with this format to only
I would like to search and replace all occurrences outside of <>. I can

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.