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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:18:40+00:00 2026-05-26T15:18:40+00:00

Im not sure how I can achieve this or if its even possible but

  • 0

Im not sure how I can achieve this or if its even possible but im trying to change one word in my url using jquery, my url is bring used multiple times with different sub directories this is what I have so far.

as you can see im trying to replace the word collections with albums

(function($) {
  var thePage = $("body");
  thePage.html(thePage.html().replace(/collections/ig, '<a href="http://mysite.com/collections/12/College-Life/most_recent/all_time/">blah blah</a>')); 
})(albums)

im not sure what to do, i happened to stumble across a site giving a little bit of detail on what to do but it wasnt much

  • 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-26T15:18:40+00:00Added an answer on May 26, 2026 at 3:18 pm

    I suspect part of your problem is that you are passing albums as the $ identifier for jQuery and that is probably not correct.

    If what you’re trying to do is to replace the word “collections” everywhere in your HTML page with a linkified version of that word, then you can use this simplified version of the code (no need to use jQuery in places it isn’t helpful):

    jQuery(document).ready(function() {
        document.body.innerHTML = document.body.innerHTML.replace(/collections/ig, '<a href="http://mysite.com/collections/12/College-Life/most_recent/all_time/">blah blah</a>');
    });
    

    I should warn you that this simple replacement will also affect occurrences of “collections” that might be in URLs in the HTML page too, not just text in the page.

    If what you’re trying to do is to change a word in the actual URL of the page, then that would take a different block of code to operate on window.location.href.


    Based on the new information in your comment, it sounds like you’re trying to change the word “collections” in all URLs in the document to “albums”. To do that, you would use code like this:

    var links = document.getElementsByTagName("a");
    for (var i = 0; i < links.length; i++) {
        links[i].href = links[i].href.replace(/\/collections\//, "/albums/");
    }
    

    This gets all the links in the document, cycles through them and replaces any occurrence of “/collections/” in the click destination for that link with “/albums/”.

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

Sidebar

Related Questions

Not sure if I can explain this correctly, but I am trying to execute
Not sure if you can do this, but I want to select the first
Not sure if yall can help this time, as I'm just using this particular
I am not sure whether it is possible to achieve this kind of implementation
I'm not sure if this is possible, but is there a way to safely
I'm not sure if this question has been asked before, but I can't seem
I'm having difficulty trying to figure this out. I'm not even sure if it's
I am not sure this can be done at all... Background: I am constructing
Not sure why I can't figure this out. When a user makes a selection,
Not sure if I can do it this way. I want to get current

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.