SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast
    Join Date
    Aug 2003
    Location
    England
    Posts
    34
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    document.write writes to a new page

    I am created a web page with a cms. It includes pansets but I don't think this should cause a problem..? I have a redirector based on IP and a simple if else statement. The else statement has a document.write, but when it is run it writes the text to a new web pages and doesnot display anything else.

    if(internal == "Y") {
    var redirect = new Redirect("http://intranet/awebpage");
    redirect.go();
    }
    else
    {
    document.write('Hello');
    }
    This is the correct way to do a document.write isn't it?

    I can't post all the code (cos its a lot) but is the document.write structed ok?

    Cheers

  2. #2
    Shiver me timbers!! anthony_irl's Avatar
    Join Date
    Aug 1999
    Location
    Dublin, Ireland
    Posts
    495
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The document.write seems OK. Try double quotes instead.
    Anthony - How's tings?

    24 hours in a day, 24 beers in a case. Coincidence? I think not.
    Contact me by: PM Email NEW! Carrier Pigeon

  3. #3
    ♪♪ ♪ ♪ ♪ ♪♪ ♪ ♪♪ Markdidj's Avatar
    Join Date
    Sep 2002
    Location
    Bournemouth, South UK
    Posts
    1,551
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    The document.write will always do this from a function after the page has loaded. If you want to change any text you will need to either use inputs, textareas or change the innerHTML or textNode of objects such as divs,p's,span's etc.
    You can use document.write to write to the current page while loading or created a new page when loaded.
    LiveScript: Putting the "Live" Back into JavaScript
    if live output_as_javascript else output_as_html end if

  4. #4
    "Of" != "Have" bronze trophy Jeff Lange's Avatar
    Join Date
    Jan 2003
    Location
    Calgary, Canada
    Posts
    2,063
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yup, basically the short answer is: You cannot write to a page after it has been loaded. You should provide some more info on what you want to do, so we can help you with something specific
    Who walks the stairs without a care
    It shoots so high in the sky.
    Bounce up and down just like a clown.
    Everyone knows its Slinky.


Bookmarks

Posting Permissions

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