Search code examples
javascriptjquerybrowser-history

Loop over "history" in javascript?


Is there a way to loop over the "history" object in javascript to find a specific page in the history?


Solution

  • Security reasons - no, you can not dump the history of the browser (with javascript)

    I mean you can not do

    // This does not work
    for (i=0; i<window.history.length; i++) {
          alert(window.history[i]);
    }
    

    However I don't have good explanation why history.go(n); is ok