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 2 of 2
  1. #1
    New Coder
    Join Date
    Mar 2003
    Posts
    64
    Thanks
    0
    Thanked 0 Times in 0 Posts

    document.write to current window

    i have this on my page:

    <head>
    <script language="javascript">
    function viewNews(article) {
    view=window.open("","view","fullscreen=0")
    view.document.write("<html><head></head><body>")
    view.document.write(article)
    view.document.write("</body></html>")
    view.window.resizeTo(400,300)
    }
    </script>
    </head>

    <body>
    <a href="javascript:viewNews('my name is loonatik')">click here</a>
    </body>

    What this does is open a new window and writes 'my name is loonatik' to that new window.

    But what I want is for the text to be written in the current window (no pop-up). Do I have to use innerHTML? I was looking for the effect of a viewnews.php. I'm using this to display articles so I wouldn't have to create separate pages for my 70+ articles. I've tried changing window.open to window.location and pointing it to a template, but it doesn't work. Any solutions?
    Thanks.

  • #2
    Senior Coder
    Join Date
    Aug 2002
    Posts
    3,467
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You can't use document.write() after the document has fully loaded. innerHTML is a viable solution.
    My Site | fValidate | My Brainbench | MSDN | Gecko | xBrowser DOM | PHP | Ars | PVP
    “Minds are like parachutes. They don't work unless they are open”
    “Maturity is simply knowing when to not be immature”


  •  

    Posting Permissions

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