History.item in Javascript

G

George

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;
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
 
R

Randy Webb

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;
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top