document.URL

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Peter UG

    #1

    document.URL

    Hi all,

    the simple script to print the current URL is fine:

    <script language="JavaS cript">

    <!--

    document.write( document.URL)

    //-->

    </script>



    but as my cgi-script receiving the URL referrer needs the actual page name,
    anyone browsing a top level directory without the index.html as in:

    HSTS Redirection Community Customer Secure Login Page. Login to your HSTS Redirection Community Customer Account.


    and the cgi-script will not work.

    So how can this javascript be done so if the document.URL end in / the
    script adds index.html.

    Any help from experts really appreciated!

    Peter.




  • Brian Genisio

    #2
    Re: document.URL

    Peter UG wrote:
    [color=blue]
    > Hi all,
    >
    > the simple script to print the current URL is fine:
    >
    > <script language="JavaS cript">
    >
    > <!--
    >
    > document.write( document.URL)
    >
    > //-->
    >
    > </script>
    >
    >
    >
    > but as my cgi-script receiving the URL referrer needs the actual page name,
    > anyone browsing a top level directory without the index.html as in:
    >
    > http://site.com/about/
    >
    > and the cgi-script will not work.
    >
    > So how can this javascript be done so if the document.URL end in / the
    > script adds index.html.
    >
    > Any help from experts really appreciated!
    >
    > Peter.
    >
    >
    >
    >[/color]


    It is difficult to know for sure that index.html is the page you are on.
    This is because the browser is never told.

    When you make a page request, such as http://site.com/about/ , the
    server has a default document assigned. The server might have
    index.html, or index.htm, or default.asp, or whatever the server is
    convigured to say.

    The server uses the default value, and reads the file, and returns data
    for the original request. So, one thing you can do, on the server, is
    do a 303 redirect of the page to the default. It depends on the server.
    Whatever you use, your browser can never know what the default page is
    named, unless it is specifically told in some way.

    Brian

    Comment

    Working...