View Full Version : Viewing history in javascript

12-13-2006, 12:42 AM
Hi, I've been messing around with javascipt and the history and I cant get it to print out my history... Here is my script:

<script language="JavaScript">
document.writeln("<B>history:</B> " + history);

That tells me its an object, which I know so I try:

<script language="JavaScript">
document.writeln("<B>history:</B> " + history[0]);

Which gives me nothing... Any help?

12-13-2006, 02:20 AM
History is protected and, in theory, should never be exposed to script for anything other than going back and forward. It would leave people vulnerable to privacy violations.
That said, I bet there are hacks out there if you look.

Puffin the Erb
12-13-2006, 11:27 AM
If the browser supports Netscape signed scripts ( such as Firefox ), then just place the following line before your code to invoke the security manager :


The user will then be able to Grant or Deny the privilege.

An error will be generated in non-supporting browsers so test for the capability first.

12-13-2006, 03:03 PM
Doesn't that require a signed script?

You can't just make any script and use that, can you?

Puffin the Erb
12-13-2006, 05:22 PM
No, it doesn't require signing, the user can decide whether they want the code to run, with or without a signature. However, they would be more likely to allow the script if it has been signed.

Personally, I would not allow, or use, such scripts for security / privacy / cross-browser compatibility reasons unless developing for an intranet, however, it is proof of concept.

12-13-2006, 08:41 PM
Ah, gotcha.
Generally speaking, I don't allow anything to run if the browser had to ask me about it in the first place. :D