By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
429,435 Members | 2,033 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 429,435 IT Pros & Developers. It's quick & easy.

History.item in Javascript

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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.