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
    Jun 2002
    Location
    Vancouver, WA
    Posts
    233
    Thanks
    2
    Thanked 0 Times in 0 Posts

    focus() after document.write crashes IE (sometimes)

    I just spent 6 hours isolating the most obscure bug. The funny thing was that putting alert messages in the code to help find it (see how far I got through the code before it crashed) stopped it from occurring.

    I'm using frames, and I use a frame called "create" to run things. "create" maintains variables and re-creates the page the users see, "image," as necessary to change the image they see.

    To re-create it I call the function makeImage().

    At the very end of makeImage(), after the document.write that actually re-creates the page, I do a focus() to place the cursor where I want it on the newly re-created page. The program runs without the focus(), but with it somewhat inconsistently IE crashes with the message "performed an illegal operation." Can't have that!

    It seems -- just guessing here -- that when it crashes it might be trying to focus() on a page that isn't fully re-created yet. Doesn't exist yet. This could happen as the page can take some time to re-create. (This would explain why placing an alert message before the focus() stopped the problem from occuring... giving it more time.)

    I need something like onDocumentDoneWriting.focus().

    Thanks for any ideas, Peter

    function makeImage(){
    c=...
    c+="</td></tr></table></center></body></html>";
    parent.image.document.write(c);
    parent.image.document.close();
    parent.image.document.f1.search.focus();
    }

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Location
    The Planet Earth Code Poet: True
    Posts
    282
    Thanks
    0
    Thanked 1 Time in 1 Post
    In your string "c" where you define the body tag how about including an onload event handler to give the window focus?

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Location
    Vancouver, WA
    Posts
    233
    Thanks
    2
    Thanked 0 Times in 0 Posts
    Thanks, but I don't understand what you mean.

    Can you give an example of syntax? I'm not sure what should be "onloaded".

    Actually, onload has puzzled me and I have never been able to make it work having tried for many different purposes over the last few years. Obviously I have trouble understanding it.

    Thanks, Peter

  • #4
    Regular Coder
    Join Date
    Sep 2002
    Location
    Louisiana
    Posts
    576
    Thanks
    0
    Thanked 0 Times in 0 Posts
    i think what he meant is add this to c

    c="<html><body onLoad='document.f1.search.focus();'>";


  •  

    Posting Permissions

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