如何使用jQuery转到URL? [英] How to go to a URL using jQuery?

查看:148
本文介绍了如何使用jQuery转到URL?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用jQuery或JavaScript转到URL。

How to go to a URL using jQuery or JavaScript.

<a href="javascript:void(0)"  onclick="javascript:goToURL()">Go To URL</a>

function goToURL(url){
// some code to go to url

}

我不想使用window.location,因为我想从弹出窗口调用此链接。

I don't want to use window.location as I want to invoke this link from a popup.

新链接也应该在弹出窗口中打开。我也不想使用Ajax。只需在JavaScript中模拟href。

New link should also open in a popup. I also don't want to use Ajax. Just simulate href in JavaScript.

推荐答案

//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";

这篇关于如何使用jQuery转到URL?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆