Jquery页面跳转 JavaScript 页面跳转 跳转路径错误问题
2015-07-08 10:51
585 查看
转载子:极客导航 - Jquery页面跳转 JavaScript 页面跳转 跳转路径错误问题
1.使用Jquery实现跳转
$(location).attr('href',"http://www.google.com"); $jq(window).attr("location","http://www.google.com"); $(location).prop('href',"http://www.google.com");
2.使用JavaScript实现跳转
// 相当于 HTTP redirect window.location.replace("http://stackoverflow.com"); // 相当于 clicking on a link window.location.href = "http://stackoverflow.com";
JavaScript其它的可实现页面跳转的方式
window.history.back(-1); // back window.navigate("top.jsp"); // old-IE-only self.location="top.htm"; top.location="error.jsp"; window.location = window.location.host; window.location.assign("http://www.mozilla.org"); document.location.href = '/path'; window.history.go(-1);
3.页面跳转路径错误问题
ie8以下的页面跳转需要使用绝对路径,使用相对路径的时候ie会自动网跳转的Url上面加上当前页面的路径,这会导致跳转错误。 下面是解决办法:function Redirect (url) { var ua = navigator.userAgent.toLowerCase(), isIE = ua.indexOf('msie') !== -1, version = parseInt(ua.substr(4, 2), 10); // Internet Explorer 8 and lower if (isIE && version < 9) { var link = document.createElement('a'); link.href = url; document.body.appendChild(link); link.click(); } // All other browsers else { window.location.href = url; } }
相关文章推荐
- jQuery Event对象
- jquery精简选项卡
- jquery的setinterval使用方法
- jQuery end()的使用
- Jquery 记录几个函数
- jquery easyui
- jQuery 实现简单全选、全不选、反选
- 15个web前端的美轮美奂的 jQuery 图片特效
- jQuery--获取Select选择的Text和 Value(转)
- jQuery源码阅读之获取jQuery对象
- jQuery实现类似淘宝网图片放大效果的方法
- jQuery实现tab选项卡效果的方法
- JQuery父节点兄弟节点孩子节点的操作
- jQuery EasyUI combobox多选及赋值、读取、回显
- Jquery怎么获取元素文档大小、偏移、位置和滚动条位置
- MVC + jQuery 三级联动
- jQuery中的Ajax实现
- jQuery选择器的使用[直接上代码]
- jQuery与DOM对象之间的转化
- jQuery全局ajax Error