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 8 of 8
  1. #1
    JPM
    JPM is offline
    Regular Coder
    Join Date
    Mar 2004
    Location
    Norway
    Posts
    204
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Writing to popUp window

    I am writing some text to a popup window, and before I write the text I use the myWindow.document.open() method, but it seems this doesnt work in netscape so the new text is just added to the text already there.
    Is there another way to do this?

    thanks
    <JPM />

  • #2
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Try writing the text at the same time you open the popup and not wait until it is already open....

  • #3
    JPM
    JPM is offline
    Regular Coder
    Join Date
    Mar 2004
    Location
    Norway
    Posts
    204
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thats what I do, but within the text I wrote when I opened the window there is a link, and when you click the the link I want to write some new text to the window/overwriting the text already there.
    <JPM />

  • #4
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by JPM
    Thats what I do, but within the text I wrote when I opened the window there is a link, and when you click the the link I want to write some new text to the window/overwriting the text already there.
    If you want to overwrite everything in the popup use the popup name and write another document.write statement.

    If you only want to replace a certain portion of the text use innerHTML...

  • #5
    JPM
    JPM is offline
    Regular Coder
    Join Date
    Mar 2004
    Location
    Norway
    Posts
    204
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thats what Im doing and I thought it would work, but it doesnt(unless I use popupwindow.document.open() before I write to it, then it works in ie.)

    There is alot of other functions and stuff in the script so I guess maybe something else is causing the problem...
    <JPM />

  • #6
    JPM
    JPM is offline
    Regular Coder
    Join Date
    Mar 2004
    Location
    Norway
    Posts
    204
    Thanks
    0
    Thanked 0 Times in 0 Posts
    If you want to overwrite everything in the popup use the popup name and write another document.write statement.
    I tried it out with this simple script and it seems that if you just do another document.write it still adds the text to text already there..


    Code:
    <html>
    <head>
    
    <script> 
    
    var test = window.open("","test","width=200,height=200")
    test.document.write("BLA BLA BLA BLA")
    
    function wMore() {
    test.document.write("BLA2 BLA2 BLA2")
    test.focus()
    }
    </script>
    </head>
    <body>
    <form>
    <input type="button" onclick="wMore()" value="write" />
    </form>
    </body>
    
    </html>

    Anyway, I fixed it by putting all the content inside a div the first time then changed it all with innerHTML.
    Last edited by JPM; 07-17-2004 at 11:05 PM.
    <JPM />

  • #7
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    While document.open() is assumed, you are not closing the document and therefore it is still open to write too....

    Code:
    <html>
    <head>
    
    <script> 
    
    var test = window.open("","test","width=200,height=200")
    test.document.write("BLA BLA BLA BLA")
    test.document.close();
    
    
    function wMore() {
    test.document.write("BLA2 BLA2 BLA2")
    test.document.close();
    test.focus()
    }
    </script>
    </head>
    <body>
    <form>
    <input type="button" onclick="wMore()" value="write" />
    </form>
    </body>
    .....Willy

  • #8
    JPM
    JPM is offline
    Regular Coder
    Join Date
    Mar 2004
    Location
    Norway
    Posts
    204
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks! I was beginning to wonder after I looked it up in the js bible and it said the document.open() was supported by browsers.
    <JPM />


  •  

    Posting Permissions

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