469,603 Members | 2,076 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,603 developers. It's quick & easy.

document.referrer value to text input

Hi,

I'm trying to put the last URL visited to a text input using
history.previous for WebTV (because I can't get document.referrer to
work with WebTV) and document.referrer for PC. This is for my Web
Resources page. Where if I go straight to it from an image that I want
to edit with an online imaging tool, or if I go straight to it from a
page that I want to validate, I can put the URL to the text input of the
portal I want to use.

I'm getting varied results with the PC (IE6). When I click on the page
that has this in my file manager it works. But when I access the page
from my favorites it doesn't work.

Here's a link to an example/test page:

http://www.xlectric.com/resources/lasttest.html

Below is the code for the forms and JavaScript that I'm using.

Thanks for any help.

Later, Art.

<form action="javascript:void()" onsubmit="return false;">
Last URL
<br />
<input type="text" id="last" size="50" />
</form>
<form id="last2" action="javascript:void()" onsubmit="return false;">
<p>
<a href="javascript:showLast('last2');">Show Last URL</a>
&nbsp;&nbsp;&nbsp;<a
href="javascript:document.getElementById('last2'). reset();">Reset</a>
<br />
<input type="text" size="50" />
</p>
</form>

<script type="text/javascript">
<!-- Xlectric Script
var s_last;
if (navigator.appName.indexOf("WebTV") != -1)
{
s_last = history.previous;
}
else
{
s_last = document.referrer;
}
document.getElementById("last").value = s_last;
function showLast(f_last)
{
document.getElementById(f_last).elements[0].value = s_last;
}
//-->
</script>

Jul 23 '05 #1
2 10055
X l e c t r i c wrote:
I'm trying to put the last URL visited to a text input
using history.previous for WebTV (because I can't get
document.referrer to work with WebTV) and
document.referrer for PC. This is for my Web Resources
page. Where if I go straight to it from an image that I
want to edit with an online imaging tool, or if I go
straight to it from a page that I want to validate, I
can put the URL to the text input of the portal I want
to use.

I'm getting varied results with the PC (IE6). When I
click on the page that has this in my file manager it
works. But when I access the page from my favorites it
doesn't work.


The history object is suspicious about reading out previous url's
because of security and privacy reasons. Things like document.referrer
and history.previous have only limited support.

The reason why it still works in your demo, is maybe because both
scripts are on the same domain.

It is a better idea to handle this kind of functionality at the server
side. See php, cgi, ssi...

--
Bart

Jul 23 '05 #2
Hi Bart,

Thanks for the reply and info.

Later, Art.

Jul 23 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Daniel | last post: by
1 post views Thread by kuok benny | last post: by
5 posts views Thread by Nospam | last post: by
reply views Thread by devrayhaan | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.