Rollup merge of #32308 - bombless:patch-2, r=alexcrichton

Fix usability problem when browse document locally

You cannot use `history.replaceState` when you browse locally, it breaks the security policy of Chrome and perhaps other browsers.
Closes https://github.com/rust-lang/rust/issues/32307
Thank @crumblingstatue for the help!
This commit is contained in:
Eduard-Mihai Burtescu 2016-03-19 12:30:00 +02:00
commit 5a5b5f1e9f

View File

@ -740,7 +740,11 @@
$(".search-input").on("keyup input",function() {
clearTimeout(searchTimeout);
if ($(this).val().length === 0) {
window.history.replaceState("", "std - Rust", "?search=");
if (browserSupportsHistoryApi()) {
history.replaceState("", "std - Rust", "?search=");
} else {
location.replace("?search=");
}
$('#main.content').removeClass('hidden');
$('#search.content').addClass('hidden');
} else {
@ -996,7 +1000,7 @@
var prev_id = 0;
function set_fragment(name) {
if (history.replaceState) {
if (browserSupportsHistoryApi()) {
history.replaceState(null, null, '#' + name);
$(window).trigger('hashchange');
} else {