Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Jul 2005
    Posts
    342
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question How to Load Whole Website's HTML Code Into Innerhtml?

    Hi,
    I have a iframe with name and id, and I have a internal html page in my server. This internal html page has all the components(like header, title, the <html> tag, etc) that can be a standalone page. I get the internal page using php code. The whole thing is using AJAX.

    I try to load this internal page into my iframe.

    The following is the code:

    In my webpage:

    <iframe name="myframe" id="myframe" width="800" height="800"></iframe>


    In my javascript:

    var myframe = document.getElementById('myframe');
    myframe.innerHTML= xmlHttp.responseText;

    I checked xmlHttp.responseText, and verified that it contain the whole internal page in html page as text. btw, the html code is quite big, it has 20000 characters. But iframe just don't show the internal page in the browser. Why? How do I fix it?

    Many thanks.

  • #2
    Regular Coder martin_narg's Avatar
    Join Date
    Jul 2002
    Location
    Chamonix, France
    Posts
    600
    Thanks
    1
    Thanked 3 Times in 3 Posts
    the iframe does not have an innerHTML property - hence the problem. However why not just load the page into the iframe to display the html?
    Code:
    document.getElementById("myframe").src = "internalHTMLpage.html";
    Hope this helps

    m_n
    "Cos it's strange isn't it. You stand in the middle of a library and go 'Aaaaaaaaaaaaaaaaggggggghhhhhhh!'
    and everybody just stares at you. But you do the same in an aeroplane, and everybody joins in."
    -Tommy Cooper

  • #3
    Regular Coder
    Join Date
    Jul 2005
    Posts
    342
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question

    It's because I need to traverse the dom tree of the content in the iframe. I can't do that because of javascript security limitation. I will have 2 different domains, and I need to sync the content in the iframe of one domain with the other domain.

    Any way to go around the innerhtml thing? I don't have to use iframe. All I want is to be able to traverse the dom tree of the content from responseText.


    Quote Originally Posted by martin_narg
    the iframe does not have an innerHTML property - hence the problem. However why not just load the page into the iframe to display the html?
    Code:
    document.getElementById("myframe").src = "internalHTMLpage.html";
    Hope this helps

    m_n

  • #4
    Regular Coder martin_narg's Avatar
    Join Date
    Jul 2002
    Location
    Chamonix, France
    Posts
    600
    Thanks
    1
    Thanked 3 Times in 3 Posts
    "Cos it's strange isn't it. You stand in the middle of a library and go 'Aaaaaaaaaaaaaaaaggggggghhhhhhh!'
    and everybody just stares at you. But you do the same in an aeroplane, and everybody joins in."
    -Tommy Cooper


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •