window.location无法与window.location.href一起使用
window.location not working with window.location.href?
我有这个代码,
$('.editLayout #changeLayout').click(function() {
$('html').height($(document).height());
$('#fluidWrap').hide('scale');
$.ajax({
data: {
mainLayout: true
},
success: function() {
alert(window.location.href);
window.location = window.location.href;
}
});
return false;
});
当alert
返回时,我得到一个带有哈希的有效url,例如
http://www.example.com/edit#_layout
但是页面不会刷新,如果我点击f5,尽管页面会正常刷新。
有什么想法吗?
尝试
window.location.reload(true);
更新(这里是铬的破解解决方案)
setTimeout(function(){window.location.reload(true);},100)
更新哈希不会重新加载页面,同样,将页面href设置为包含哈希的href也不会刷新页面。试试这个:
alert(window.location.href);
window.location = window.location.href.split('#')[0];
尝试
window.location.href = window.location.href;
相关文章:
- window.location替换并传递URL历史记录条目中的变量
- 可以<脚本类型=“;text/javascript”>window.location=“/"</
- window.location使用jquery mobile实现chrome跳转
- Windows.Open 在 window.Location 工作时不起作用
- 如何将所有作业自定义到window.location.href
- window.location未刷新到现有URL
- 如果window.location.href.indexOf('player=1')添加样式
- 在$state.go之后执行$window.location.reload(true)
- javascript window.location在检查firebug时给了我一个错误的url路径
- angularjs 中 $window.location.reload() 和 $route.reload() 之间的区
- 在AJAX中使用window.location.replace'成功'回调
- IE中不支持JQuery window.location.hash
- PhoneGap如何在更改window.location/document.location后保持Javascript的
- 如何在更改window.location后停止执行
- 警报中的window.location必须重定向到上一页
- 如何在窗体操作或window.location(PHP)中使用数据切换
- 正在将目标添加到window.location
- window.location.htm无法在chrome扩展中工作
- 可以'当window.location.href时,无法从javascript获取post值
- 基于AJAX的网站中的JS window.location