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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T20:58:21+00:00 2026-05-14T20:58:21+00:00

Scenario: I am using jQuery to lazy load some html and change the relative

  • 0

Scenario: I am using jQuery to lazy load some html and change the relative href attributes of all the anchors to absolute links.

The loading function adds the html in all browsers.

The url rewrite function works on the original DOM in all browsers.

But

In IE7, IE8 I can’t run that same function on the new lazy loaded html in the DOM.

//lazy load a part of a file
$(document).ready(function() {
   $('#tab1-cont')
       .load('/web_Content.htm #tab1-cont');
   return false;
});
//convert relative links to absolute links
$("#tab1-cont a[href^=/]").each(function() {
    var hrefValue = $(this).attr("href");
    $(this)
       .attr("href", "http://www.web.org" + hrefValue)
       .css('border', 'solid 1px green');
    return false;
});

I think my question is: whats the trick to getting IE to make selections on DOM that is lazy loaded with jQuery?

This is my first post. Be gentle 🙂

Thanks,

Joel

  • 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-14T20:58:22+00:00Added an answer on May 14, 2026 at 8:58 pm

    If you have ever wanted to lazy load some HTML using jquery .load() you need to know that IE and FF don’t treat relative HREFs the same way. IE adds a ghost domain to the relative URL (to the lazy loaded html).

    As a result, if you load a DIV of content full of HREFs you cannot count on using $(a[href^=/]) to find all relative HREFs. IE won’t have any.

    So I wrote this:

    (Bear with me, I’m a CSS guy who does some jQuery. I know this could be written MUCH more elegantly. Could someone help me out with that?)

    $('.footer-wrap').ready(function() {
        $('.tab1-cont').load('/web_Content.htm .tab1-cont');
        return false;
    });
    $(".footer-wrap").hover(function() {
        //Step 1
        //IE seems to add a ghost domain to lazy loaded html.  In my case, "site.heritage" is the domain, so IE added to lazy loaded href URL.
        //So I sniff for "site" in the URL
        $(".footer-wrap a[href*=site]")
        //on all results
        .each(function() {
            //clean up the ghost domain by getting the href and replacing "http://site.web.org" with nothing
            var hrefValue = $(this).attr("href").replace('http://site1.web.org', '').replace('http://site2.web.org', '').replace('http://site.web.org', '');
            //add the proper domain to the clean relative href URL
            $(this).attr("href", "http://www.web.org" + hrefValue);
        });
        //Step 2
        //FF just needs this to make a relative url into an absolute URL because it treats lazy loaded html like regular html.
        $(".footer-wrap a[href^=/]")
        .each(function() {
            var hrefValue = $(this).attr("href");
            $(this).attr("href", "http://www.web.org" + hrefValue);
        });
    });
    

    Perhaps lazy loaded HREFs in IE don’t act this way for all people all the time… and I just found some niche circumstance. I don’t know. Hopefully this HREF post will save someone some time.

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

Sidebar

Related Questions

No related questions found

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.