开发者

Loop over "history" in javascript?

开发者 https://www.devze.com 2022-12-14 20:03 出处:网络
Is there a way to loop over the \"history\" object in javascript to find a开发者_如何学Python specific page in the history?Security reasons - no, you can not dump the history of the browser (with java

Is there a way to loop over the "history" object in javascript to find a开发者_如何学Python specific page in the history?


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


No, because it would you the ability to basically spy on the web history of anyone visiting your site (you could send this information to your server using Javascript).

You can redirect the client to particular pages in their history using the Javascript history object's back(), forward(), and go() methods. You just can't know where exactly you're redirecting them (except in the case of using go() to redirect to a URL instead of a history number).

0

精彩评论

暂无评论...
验证码 换一张
取 消