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

  • Home
  • SEARCH
  • 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 3595658
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T19:52:53+00:00 2026-05-18T19:52:53+00:00

Say you have a link with a relative path that looks like this: <a

  • 0

Say you have a link with a relative path that looks like this:

<a id="link" href="/folder/filename.php">Link Text</a>

and you try to grab that href using Mootools code like this:

$('link').get('href');

That will return /folder/filename.php in every browser but IE which literally inserts the domain for you, returning http://www.domain.com/folder/filename.php.

Is there a way around this? If not, how can I reliably grab everything but the domain in all browsers? String matching will be a pain because this site is currently being tested on three different domains, not to mention the different people doing local testing with who knows what combination of localhost, port number, and whatever else.

  • 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-18T19:52:54+00:00Added an answer on May 18, 2026 at 7:52 pm

    You’re probably best off testing to see if the URL starts with a URI scheme plus domain. This avoids the odd-but-perfectly-valid case where the domain exists in the path.

    var href = $('link').get('href'),
        prefix = location.protocol + "//" + location.hostname;
    if (href.indexOf(prefix) === 0) {
        href = href.substring(prefix.length);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say you have a link with a relative path that looks like this: <a
Say I have an anchor link like: <a id=page-contact rel=shadowbox;width=640;height=400 href=/contact.php>link here</a> How would
Say I have the following markup: <li><a href="somehwere">Link text</a></li> If I have a background
Say I have a URL: <a href=hello.html id=4298>hello</a> When someone clicks this link, I
Let's say I have a links like this: http://mysite.com?i=343435&f=224&u=334 and this link is constant
Say I have a class named Frog, it looks like: public class Frog {
lets say we have a link <a href=/something target=_new>blah</a> and now i want a
I have a scrollable area that contains popup menus. Conceptually, something like this: <div
Let's say I have a link in a table like: <td class=ms-vb width=100%> <a
This is regarding ASP.NET MVC. Let's say I have a web site that 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.