473,379 Members | 1,245 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,379 software developers and data experts.

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 4789
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Ashot | last post by:
This is sort of both Python and Vim related (which is why I've posted to both newsgroups). Python related: ---------------------- I have been frustrated for quite some time with a lack of a...
15
by: Peter Bremer | last post by:
Hi all, I've written this little piece of code, which doesn't seem to work in Mozilla 1.5. I haven't tried it on other Gecko browsers, but I've found some indication that Netscape 6+ has the...
2
by: harry | last post by:
I have a search form that returns a search results list. The user then selects a result which displays full info for that selected item. The item then has 6 different pages all showing related...
3
by: Jake | last post by:
Im using some custom javascript:history.forward() & javascript:history.back() image buttons on my application. If there is no back or forward history, I would like to display a dimmed(disabled...
4
by: Ike | last post by:
Can someone show me how I can have: <a href="javascript:history.back()" name="Back" value="Back" style=width:40px;float:right;margin-left:0px class="button" >Back</a> but since this href...
4
by: Tim Marsden | last post by:
Hi, If I navigate from Page1 to Page2 then to Page3, using the response.redirect. When the user press the Back button, I what then to go to Page 1 and start again, not Page2. I dont want the...
20
by: Dan | last post by:
Is there a way to obtain the last page visited? I don't want to go to that page, I just want to be able find out what page they came from, the url of that page. Is this possible?
3
by: Niall | last post by:
When I say 'last', I mean (eg.) the 100th item in a 100-item history list, *not* the immediately previous one! The problem is, the history.go() method only allows *relative* movement through...
0
by: ummaria | last post by:
Hello, I have posted a question related to this problem before but I never got the full understanding of the concept. I would really appreciate if someone could help me, my deadline for the design...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.