DOM window.top.location

Discussion in 'HTML' started by Vince Morgan, Nov 11, 2006.

  1. Vince Morgan

    Vince Morgan Guest

    Hi All,
    I beleive [window.top.location] is part of the HTML DOM.
    The reason I ask is that if it does work I'll structure my no javascript
    fallback arrangement like below.

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <title></title>
    <script type="text/javascript">
    window.top.location="MyJavaPage.html";
    </script>
    </head>
    <body onLoad="window.top.location='NoJavaPage.html';" id="main" class="">
    <p></p>
    </body>
    </html>

    If it doesn't, I'm quite lost as to how to achieve a graceful fallback.
    I know I could just let it fall through and have the non-JS enabled content
    within the body. However, for the sake of speed, and that the JS enabled
    page should actualy be the default, I would prefer to do it as above or
    similar.
    Any comments or help is very much appreciated.
    TIA,
    Vince Morgan
    Vince Morgan, Nov 11, 2006
    #1
    1. Advertising

  2. Vince Morgan

    Vince Morgan Guest

    "Vince Morgan" <> wrote in message
    news:4555763b$0$19406$...

    > <body onLoad="window.top.location='NoJavaPage.html';" id="main" class="">


    Please excuse the 'id' & 'class' within the body tag.
    It was cut from some rubbish code with too much haste :)
    Vince Morgan
    Vince Morgan, Nov 11, 2006
    #2
    1. Advertising

  3. Vince Morgan wrote:
    > Hi All,
    > I beleive [window.top.location] is part of the HTML DOM.
    > The reason I ask is that if it does work I'll structure my no javascript
    > fallback arrangement like below.
    >
    > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    > "http://www.w3.org/TR/html4/strict.dtd">
    > <html>
    > <head>
    > <title></title>
    > <script type="text/javascript">
    > window.top.location="MyJavaPage.html";
    > </script>
    > </head>
    > <body onLoad="window.top.location='NoJavaPage.html';" id="main" class="">


    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    That's JavaScript between the two quotes! It will not work if JavaScript
    is disabled

    > <p></p>
    > </body>
    > </html>
    >
    > If it doesn't, I'm quite lost as to how to achieve a graceful fallback.
    > I know I could just let it fall through and have the non-JS enabled content
    > within the body. However, for the sake of speed, and that the JS enabled
    > page should actualy be the default, I would prefer to do it as above or
    > similar.
    > Any comments or help is very much appreciated.


    The only way I can see it to make this page the non-JavaScript page and
    use JavaScript function to change to the JavaScript page, that way the
    page will only be redirected *if* JavaScript is enabled.

    --
    Take care,

    Jonathan
    -------------------
    LITTLE WORKS STUDIO
    http://www.LittleWorksStudio.com
    Jonathan N. Little, Nov 11, 2006
    #3
  4. Vince Morgan

    Vince Morgan Guest

    "Jonathan N. Little" <> wrote in message
    news:de0d1$4555cd88$40cba7bf$...
    > > <body onLoad="window.top.location='NoJavaPage.html';" id="main"

    class="">
    >
    > ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    > That's JavaScript between the two quotes! It will not work if JavaScript
    > is disabled
    >
    > > <p></p>
    > > </body>
    > > </html>

    > The only way I can see it to make this page the non-JavaScript page and
    > use JavaScript function to change to the JavaScript page, that way the
    > page will only be redirected *if* JavaScript is enabled.
    >
    > --
    > Take care,
    >
    > Jonathan


    Thank you very much Jonathan.
    I think your idea is a good one. However, I couldn't find a way for the
    non-JS page not to show prior to the redirection.
    There is another way though. One that allows for a very small switchboard
    type page.

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <title></title>
    <meta http-equiv="Refresh" content="0; url=Non-JS-Page.html">
    <script type="text/javascript">
    window.top.location="JS-Page.html";
    </script>
    </head>
    <body>
    <p></p>
    </body>
    </html>

    I don't have enough knowledge about <meta>, or any html for that matter, to
    know if the above will work in most browsers.
    My previous programming experience is with languages that are lower level
    and strictly standardised so I'm finding it a bit difficult following all
    the incompatibilities in browsers.
    Having said that, do you see any serious issues with the above code?
    Thank you again Jonathan,
    Vince
    Vince Morgan, Nov 12, 2006
    #4
  5. Vince Morgan

    Vince Morgan Guest

    OT

    Previously I posted about sending and recieving data without having to
    re-transmit the entire page.
    You (Jonathan) offered a php solution that works well, however it does,
    naturaly, send back an entire page.
    In fact that solution is now running fine on the company's server.
    I couldn't help continuing my search for a solution that didn't require
    re-transmition of the page itself, and I found one.
    My thinking was along the lines of an activex type page, and that is where
    'XMLHttpRequest' was originaly implemented apparently.
    'XMLHttpRequest' allows for the transmision of data back to the client
    without having to send the entire page.
    So far my limited testing has shown it to be very quick, and it seems to be
    quite widely supported too.
    I thought you may find it interesting, and perhaps usefull.
    Thank you again Jonathan,
    Regards,
    Vince
    Vince Morgan, Nov 12, 2006
    #5
  6. Vince Morgan wrote:
    > "Jonathan N. Little" <> wrote in message
    > news:de0d1$4555cd88$40cba7bf$...
    >>> <body onLoad="window.top.location='NoJavaPage.html';" id="main"

    > class="">
    >> ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    >> That's JavaScript between the two quotes! It will not work if JavaScript
    >> is disabled
    >>
    >>> <p></p>
    >>> </body>
    >>> </html>

    >> The only way I can see it to make this page the non-JavaScript page and
    >> use JavaScript function to change to the JavaScript page, that way the
    >> page will only be redirected *if* JavaScript is enabled.
    >>
    >> --
    >> Take care,
    >>
    >> Jonathan

    >
    > Thank you very much Jonathan.
    > I think your idea is a good one. However, I couldn't find a way for the
    > non-JS page not to show prior to the redirection.
    > There is another way though. One that allows for a very small switchboard
    > type page.


    Then you are not really disabling JavaScript.

    >
    > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    > "http://www.w3.org/TR/html4/strict.dtd">
    > <html>
    > <head>
    > <title></title>
    > <meta http-equiv="Refresh" content="0; url=Non-JS-Page.html">

    ^^^
    I believe on meta refresh the content must be a non-zero value.

    > <script type="text/javascript">
    > window.top.location="JS-Page.html";
    > </script>
    > </head>
    > <body>
    > <p></p>
    > </body>
    > </html>
    >
    > I don't have enough knowledge about <meta>, or any html for that matter, to
    > know if the above will work in most browsers.
    > My previous programming experience is with languages that are lower level
    > and strictly standardised so I'm finding it a bit difficult following all
    > the incompatibilities in browsers.
    > Having said that, do you see any serious issues with the above code?


    Look, with page non-js.html:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <title>Non-JavaScript Page</title>

    <script type="text/javascript">
    window.top.location="js-page.html";
    </script>

    </head>
    <body>
    <p>This is the Non-JavaScript Page, no redirect will occur if JavaScript
    is disabled</p>
    </body>
    </html>

    And js.html:

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
    "http://www.w3.org/TR/html4/strict.dtd">
    <html>
    <head>
    <title>JavaScript Page</title>
    </head>
    <body>
    <p>This is the JavaScript Page, you will only reach here is JavaScript
    is enabled</p>
    </body>
    </html>

    So the logic flow is:

    Call the Non-JavaScript page which as the JavaScript function
    JavaScript is enable?
    YES, then JavaScript function redirects bowser to JavaScript page
    NO, then no redirection occurs and the Non-JavaScript page remains


    --
    Take care,

    Jonathan
    -------------------
    LITTLE WORKS STUDIO
    http://www.LittleWorksStudio.com
    Jonathan N. Little, Nov 12, 2006
    #6
  7. Vince Morgan

    Neredbojias Guest

    To further the education of mankind, "Vince Morgan"
    <> vouchsafed:

    > Thank you very much Jonathan.
    > I think your idea is a good one. However, I couldn't find a way for
    > the non-JS page not to show prior to the redirection.


    Do a document.write to style, say, the body of the non-j/s page invisible.


    --
    Neredbojias
    Infinity has its limits.
    Neredbojias, Nov 16, 2006
    #7
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?RHVzdGluIElJLg==?=

    make a browser window stay on top window handle?

    =?Utf-8?B?RHVzdGluIElJLg==?=, Aug 18, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    870
    Mark Rae
    Aug 18, 2004
  2. Scott

    window.top.location.href

    Scott, Dec 22, 2003, in forum: ASP General
    Replies:
    7
    Views:
    333
    Roland Hall
    Dec 31, 2003
  3. find clausen

    window.opener.top.location.top.close ???

    find clausen, Oct 5, 2003, in forum: Javascript
    Replies:
    2
    Views:
    433
    find clausen
    Oct 5, 2003
  4. saiho.yuen
    Replies:
    3
    Views:
    421
    kaeli
    Sep 14, 2004
  5. Larry  Viezel

    accessing window.top.location

    Larry Viezel, Feb 21, 2006, in forum: Javascript
    Replies:
    2
    Views:
    109
    Larry Viezel
    Feb 22, 2006
Loading...

Share This Page