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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T20:32:46+00:00 2026-06-14T20:32:46+00:00

I have following URL in my few pages(http://something.com).. <a href=http://something.com>Home</a> <a href=index.html>Index</a> <a href=about.html>About</a>

  • 0

I have following URL in my few pages(http://something.com)..

<a href="http://something.com">Home</a>
<a href="index.html">Index</a>
<a href="about.html">About</a>
<a href="contact.php">Contact</a>
<a href="#">Same</a>
<a hre="http://example.com/home.html">New Home</a>
<a href="../services.html">Services</a>

and what I want is to convert all link to…

<a href="http://this.com/?url=http://something.com">Home</a>
<a href="http://this.com/?url=http://something.com/index.html">Index</a>
<a href="http://this.com/?url=http://something.com/about.html">About</a>
<a href="http://this.com/?url=http://something.com/contact.php">Contact</a>
<a href="#">Same</a>
<a hre="http://this.com/?url=http://example.com/home.html">New Home</a>
<a href="../services.html">Services</a>

So Basically I don’t want to Convert "#" or "../" such link.

I am noob in JS.

From my effort, with the help of w3schools.. What i have tried to accomplish :-

<script type="text/javascript">
var url= document.getElementByTagName(a);
var pattern = /..\//g;
var result = pattern.test(url);
if(url.href != "#" || result === "false" ) {
var nurl = url.replace("http://this.com/?url="+url.href, url.href);
}
</script>

And I am not able to do anything… Please help, how can I modify URL and add http://this.com/?url=My_web_page_url_here.

UPDATE
I replaced my javascript with

<script type="text/javascript">
var links = document.links;
var i = links.length;

while (i--) {
    if (links[i].href.slice(-1) == "#" || 
        links[i].getAttribute("href").slice(0, 3) == "../") {
        continue;
    }
    links[i].href = "http://this.com/?url=" + encodeURIComponent(links[i].href);
}​
</script>

And still all url’s are in the same way without append.

  • 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-06-14T20:32:47+00:00Added an answer on June 14, 2026 at 8:32 pm

    Try this…

    var links = document.links;
    var i = links.length;
    
    while (i--) {
        if (links[i].href.slice(-1) == "#" || 
            links[i].getAttribute("href").slice(0, 3) == "../") {
            continue;
        }
        links[i].href = "http://this.com/?url=" + encodeURIComponent(links[i].href);
    }​
    

    jsFiddle.

    I encoded the parameter, but if you don’t want it encoded, like in your examples, drop the call to encodeURIComponent().

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

Sidebar

Related Questions

How do I make the following url forbidden in apache; main/index.php?site=ing I have tried
I have the following url http://localhost/user/MyUserName How do I get MyUserName from that url?
I have the following URL: https://api.stackexchange.com/2.0/questions?page=1&pagesize=30&order=desc&sort=activity&site=stackoverflow When I type this URL in my browser's
I have the following URl: http://localhost:12981/BaseEvent/EventOverview/12?type=Film This is route: routes.MapRoute( Default, // Route name
I want to have possibility to access action by the following URL type: http://localhost/MyControllerName/MyActionName/Id1+Id2+Id3+Id4
We have few downloaded HTML pages, with broken links (relative paths), and we have
I have a few pages that needs a userId to work, thus the following
I have the following URL which links to the product page of a Mac
I have the following url structure in rails routes: match '/financial-dictionary/:letter' => 'learning_center#dictionary', :as
I am trying to install ruby-mp3info. I have the following URL from which I

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.