469,641 Members | 1,116 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

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

History.item in Javascript

Dear All,

I am trying to write a simple script that prints out all the URLs in the
history of the current window. I wrote this code:

<html>
<head>
<title>Example Page</title>
<script text="javascript">
var intlen = history.length;
var i;
document.write("There are " + intlen + " windows in the history");
for (i = 0; i < intlen; i++){
var wina = history[i];
document.write(wina.document.URL);
document.write("<BR>");
}
</script>
</head>
<body>
<p>This is a test.</p>
</body>
</body>
</html>

However, when I run it I get the number of history items correctly as well
as an Access Refused to history.item message.

How can I avoid that? I remember reading somewhere that allowing this
would be a security risk - could someone please explain why?

I look forward to hearing from you soon.

Thanks in advance.

George
Feb 20 '07 #1
1 4633
George said the following on 2/20/2007 10:13 AM:
Dear All,

I am trying to write a simple script that prints out all the URLs in the
history of the current window.
You have two options:

1) Give up now and save yourself some grief.
2) Go through some grief and then give up.
I wrote this code:

<html>
<head>
<title>Example Page</title>
<script text="javascript">
var intlen = history.length;
var i;
document.write("There are " + intlen + " windows in the history");
for (i = 0; i < intlen; i++){
var wina = history[i];
document.write(wina.document.URL);
document.write("<BR>");
}
</script>
</head>
<body>
<p>This is a test.</p>
</body>
</body>
</html>

However, when I run it I get the number of history items correctly as well
as an Access Refused to history.item message.
Yep. The URL of where I have been is none of your business.
How can I avoid that?
Stop trying to read the URL's of the sites I have visited.
I remember reading somewhere that allowing this
would be a security risk - could someone please explain why?
Because where I have been - or where I might go - is none of your
business. It's that simple.

--
Randy
Chance Favors The Prepared Mind
comp.lang.javascript FAQ - http://jibbering.com/faq/index.html
Javascript Best Practices - http://www.JavascriptToolbox.com/bestpractices/
Feb 21 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by harry | last post: by
3 posts views Thread by Jake | last post: by
4 posts views Thread by Ike | last post: by
4 posts views Thread by Tim Marsden | last post: by
20 posts views Thread by Dan | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.