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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T09:39:33+00:00 2026-05-19T09:39:33+00:00

I am loading a page via AJAX and putting it in a DIV. Including

  • 0

I am loading a page via AJAX and putting it in a DIV. Including HTML tags and all. No browser seems to be worried about that, except for the fact that the <head> elements never load in IE, but do so in FF.

Is it possible to let the elements in <head> to load as well, or do I have to put them in the body?

This includes <title> and <link>. But the <style> element works fine. So I can’t load my external stylesheets with my Ajax. Is there a way, or do I have to put it in the body?

Thanks in advance.

Code example:

// page to load
<html>
<head>
    <link href="{$cssLink}" type="text/css" rel="stylesheet"> // doesn't load
    <style type="text/css">
    /* CSS bla does work*/
    </style>
</head>
<body>
    <div id="testPage_content" class="content">
</div>
</body>
</html>

And the ajax call I am making, if you would need that in your answer.

// ask for the page
$.ajax(
{
    url: "Scripts/loader.php",  
    type: "GET",        
    data: data, // created above this call
    cache: false,
    success: function (html) 
    {               
        //add the content retrieved from ajax and put it in the #content div
        $('#content').html(html);       

        // only use fading if opacity is supported          
        if($.support.opacity)
        {
            $('#loading').hide();
            $('#content').fadeIn();
        }
    }
});
  • 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-19T09:39:33+00:00Added an answer on May 19, 2026 at 9:39 am

    You really should use an <iframe> element to load a “complete” website (means with <html>, <body> and <head> tags. It’s 100% invalid markup otherwise.

    I meantioned it would be nasty work to strip, but.. woh maybe not that nasty:

    success: function (html) 
    {               
        //add the content retrieved from ajax and put it in the #content div
        var stripped = $(html),
            head     = document.getElementsByTagName('head')[0] || document.documentElement;
    
        stripped.find('head').contents().each(function(index, node) {
            if(node.nodeType !== 3) {
               node.setAttribute('data-insertID', 'foobar');
               head.appendChild(node, head.firstChild);
            }
        });
    
        $('#content').html(stripped.find('body').contents());       
    
        // only use fading if opacity is supported          
        if($.support.opacity)
        {
            $('#loading').hide();
            $('#content').fadeIn();
        }
    }
    

    Delete with:

    $('head').find('[data-insertID]').remove();
    

    This would grab all nodes from the head section of your received site and put it into your actuall website. After that it gets all nodes from the <body> tag and puts those into your div.. should work, let me know 🙂

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

Sidebar

Related Questions

I'm loading external page via jquery.ajax: $(#mydiv).load(filter.html); content of example.html: <div id=filterdiv><input id=filter name=filter
I'm loading image tags via AJAX and inserting them with the conventional .html(content) function
I have page loading, via AJAX a PHP page into a div. In turn,
I'm loading html page via Ajax. Here's the data: <input type=checkbox name=dis_net id=dis_net value=1
I'm loading some content into a jquery-ui dialog via .ajax. That's all working fine
I have the following html code: (that gets loaded via ajax into a div)
I have a page that loads a div via AJAX. The AJAX POST call
I got this jQuery pre-loading script running on a index.html page loading about 10Mb
I loaded the following HTML via Ajax into a web page powered by jQuery
In Google Chrome, AJAX called within $(function(){....}); seems to keep the page loading. 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.