PDA

View Full Version : document.referrer and image loading


shashgo
09-23-2002, 08:09 PM
I hav two questions

1) I need to know how I can use javascript to refer to pages that are linked to. I tried to display document.referrer on the new page but it doesnt return anything

so if I have a page (say one.htm) with a link
<a href="two.htm">two</a>

and in two.htm I write
<script language="javascript">
document.write("Referred to by: "+document.referrer);
</script>

then shouldnt h output be Referred to by: one.htm
I only get Referred to by:

Why is it not working? What am I doing wrong?

-----------------
2) I want to design a web page where I use javascript to load all the images on my hard drive without me having to specify each individual name. The images have filenames that are 1.jpg, 3.jpg, 4.jpg, 7.jpg, 10.jpg, 15.jpg, 30.jpg,... no order.

How can I accomplish this?

Josh
09-24-2002, 04:32 AM
I've just figured out 1),try this:first.html:
<a href="second.html">blah</a>
<script>
document.cookie=document.location;
</script>
second.html:
<script>
document.write(document.cookie);
</script>HTH

shashgo
09-24-2002, 09:30 AM
Hi Josh,

Your code works. But it uses cookies. If nothing else, Ill probably do what you said. But then does document.referrer ever work, an if so how is it used?

Josh
09-24-2002, 03:38 PM
I think it could only use cookies.
Document.referrer never works,I duno why.

David.Prout
09-26-2002, 07:19 AM
document.referer does not work if you are only browsing the files on a local drive, eg C: drive. It does work if you are browsing the files hosted on a web site, eg http://TestSite.com/testsite/test.html.

Hope that helps.

David.Prout
09-26-2002, 07:20 AM
Of course http://TestSite.com/testsite/test.html does not exist, it's just an example url for when browing a file hosted on a web site/server.

:)

Josh
09-26-2002, 03:32 PM
But I've upload it to my sever,still doesnt't work

Josh
09-27-2002, 02:10 AM
Check this link,it really doesn't work.
http://home.kimo.com.tw/asdfghjkl953/test.html

David.Prout
09-27-2002, 02:13 AM
I went to that link, from the link you posted on this forum, and document.referrer worked. The forum page I came from was show in the browser (IE6 with SP1).

Josh
09-27-2002, 02:42 AM
Now I know how to use it,thanks.
2shashgo:this is another code:first.html:
<a href="second.html">blah</a>second.html:
<script language=javascript>
document.write(document.referrer);
</script>