How to go to a URL using jQuery?
This question already has an answer here:
//As an HTTP redirect (back button will not work )
window.location.replace("http://www.google.com");
//like if you click on a link (it will be saved in the session history,
//so the back button will work as expected)
window.location.href = "http://www.google.com";
为什么不使用?
location.href='http://www.example.com';
<!DOCTYPE html>
<html>
<head>
<script>
function goToURL() {
location.href = 'http://google.it';
}
</script>
</head>
<body>
<a href="javascript:void(0)" onclick="goToURL(); return false;">Go To URL</a>
</body>
</html>
window.location is just what you need. Other thing you can do is to create anchor element and simulate click on it
$("<a href='your url'></a>").click();
链接地址: http://www.djcxy.com/p/1936.html
上一篇: jQuery位置href
下一篇: 如何去使用jQuery的URL?