If I use history.back()
for button press then what will happen?
Will the HTML content be displayed from the local history of t开发者_运维问答he browser or the cache and without the browser requesting to the server? Or will the browser request to the server based on the URL that resides in history of browser?
Calling "history.back()" in JavaScript is the same as hitting the back button in the browser's user interface (however, there can be slight differences if the currently viewed location contains frames and those have been navigated, if you're pedantic).
As for if the result comes from the server or "cache": it's up to the user agent (browser). The specification (RFC 2616 section 13.13, http://256stuff.com/gray/docs/rfc2616/13.html#13.13) says:
History mechanisms and caches are different. In particular history
mechanisms SHOULD NOT try to show a semantically transparent view of the
current state of a resource. Rather, a history mechanism is meant to show
exactly what the user saw at the time when the resource was retrieved.
However, the user agent implementation quality differs. For example, the relevant meta bug for Mozilla/Firefox can be found at https://bugzilla.mozilla.org/show_bug.cgi?id=288462
If the page you're trying to "back" to has suitable caching headers, it will be fetched from a cache instead of from the server.
This is browser dependent.
The behavior of the history.back()
button is up to the browser manufacturer.
history.go(-1) does the very same thing and is the same across all browsers...
if (!defined('MODULE_FILE'))
{
$back = "<script>history.go(-1);</script>";
print_r($back);
}
精彩评论