Undefined because your PC is not from a valid URL
- test it on line on a server
--
| Jon,
| I was interested to see what the value of referer was
|
| I have this code in index_main.html (a frame)
| <a href="bettercalc.html">
|
| In bettercalc.html, I have this code in the head
| <script type="text/javascript">
| alert(location.href + ' ' + document.referer)
| </script>
|
| The alert returns the location of bettercalc.html (on C: drive, as I am
| testing locally) and 'undefined'
|
| Why is it 'undefined' and not 'index_main.html'
|
| I tried the same thing from a new file 'test.html' (not a frame) and got the
| same result
|
| --
| Cheers,
| Trevor L.
| Website:
http://tandcl.homemail.com.au
|
| Jon Spivey wrote:
| > I'd check for a referer on each page if it's blank or not from your
| > site then redirect to the home page -
| > <script>
| > if(!document.referer || document.referer.indexOf('you.com')
| > == -1)location.replace('index.htm');
| > </script>
| >
| > --
| > Cheers,
| > Jon
| > Microsoft MVP
| >
| > | >> Any script like that in a no frames site will make it impossible to
| >> open any other page, even from the home page.
| >> You need to check if the home page has been visited, and that means
| >> checking for a cookie or session variable before doing the
| >> redirection. Using a session variable is the best way, since it
| >> requires server side scripting (ASP, PHP, Perl/CGI etc.) but
| >> JavaScript cookies will also work, except where the user has
| >> JavaScript and/or cookies disabled. See
http://irt.org/script/cookie.htm
| >> for information on setting and
| >> reading JavaScript Cookies - you may be able to adapt
| >>
http://irt.org/script/1360.htm to your needs.
| >> --
| >> Ron Symonds
| >> Microsoft MVP (FrontPage)
| >> Reply only to group - emails will be deleted unread.
| >>
| >> | >>> Yes, for sure
| >>> Although some experts here have frowned on it.
| >>>
| >>> In every page, place this
| >>> <body onload="detect();">
| >>> where detect() is a function in a linked external JS file
| >>> (Use this in the head section: <script type="text/javascript"
| >>> src="scripts/external.js"></script> )
| >>>
| >>> function detect()
| >>> {
| >>> if (parent.location.href == window.location.href)
| >>> parent.location.href = "index.html" // Put your home page
| >>> here }
| >>>
| >>> It says that if you entered this page direct, load "index.html"
| >>>
| >>> At least this works or me, where I have frames. Perhaps
| >>> parent.location isn't defined when there are no frames. (As a
| >>> relative beginner, I am not sure about this point.)
| >>> --
| >>> Cheers,
| >>> Trevor L.
| >>> Website:
http://tandcl.homemail.com.au
| >>>
| >>> Rob wrote:
| >>>> Is there a way to control entrance to my website? What I mean is
| >>>> there a way to make sure people have to come thru my index page
| >>>> before accessing anywhere else?
| >>>>
| >>>> I guess there is a way to do this because the pay sites do it all
| >>>> the time so I guess I am really asking how to do it. My site is
| >>>> not a pay site. I just want folks to come in a certain way.
| >>>>
| >>>>
| >>>> thanks
|
|