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 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Jun 2009
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Assigning the an entire document

    I am barely familiar with javascript. I have this html code with an embedded iframe. The html file in the iframe refreshes every once in a while. That is fine. However, in IE, there is this annoying click with every refresh.

    I googled a bit and saw a few solutions. Seem to me that if I fetched the contents of the HTML file (AJAX call) and assigned it to existing document, I may get around the problem.

    1. How do I assign an entire document in JS?

    2. If I did this would this prevent the clicks?

  • #2
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,079
    Thanks
    203
    Thanked 2,542 Times in 2,520 Posts
    Quote Originally Posted by rajivp View Post
    1. How do I assign an entire document in JS?

    2. If I did this would this prevent the clicks?
    1.
    Code:
    window.onload=function(){
    var str = document.getElementsByTagName('html')[0].innerHTML;
    alert (str);
    }
    2. No idea. Try it.


    Login?: yes
    Password: i dont have one
    password is incorrect

    Login?: yes
    Password: incorrect

  • #3
    New to the CF scene
    Join Date
    Jun 2009
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you for your response. I am going to try it. However, I need a bit of a clarification. Perhaps, to begin with I should have posted the code where I am trying to do this. I am trying to get the contents from a URL with a synchronous AJAX call and then do the assignment. As I am not too familiar with JS the reverse assignment and the alert has me confused. Could you please explain this a bit. I have given below the code snippets.

    This is what I currently have (which causes the click to occur)

    window.location = myurl;

    Here is what I am trying to do in a javascript function using AJAX

    receiveReq.open("GET", myurl, false);
    receiveReq.send(null);
    var response = receiveReq.responseText;

    When the response comes back I need to replace the whole document, in a manner similar to an assignment

    Thanks

  • #4
    Regular Coder
    Join Date
    Mar 2006
    Posts
    728
    Thanks
    35
    Thanked 132 Times in 123 Posts
    The 'click' is a sound IE attaches to 'navigation complete' from a window or frame. It is user controlled, and is set or removed from the control panel sounds applet.

  • #5
    New to the CF scene
    Join Date
    Jun 2009
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I realize that the click is an IE thing as it does not happen in Firefox. However, one cannot expect the visitor (to one's site) to turn off this. I have not figured out how to replace entire document. I looked around for only a little while and could not find much.

    I am thinking of going a different route. I will try and modify the code that generates the 'reload' HTML. If the reload is happening because of a refresh, I will try an return only part of the HTML that changed and use innerHTML to replace the content. This may be what I should have been doing to begin with. Hope this solves my problem.

    However, I would still like to find out if there is any way one can replace the entire HTML using something like the innerHTML


  •  

    Posting Permissions

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