MVC JavaScript 的 window.open 添加到 url
我正在使用 MVC3 和 jQuery。我正在尝试打开外部网站。我使用点击事件(而不是链接),因为我有一些自定义逻辑,可以将值添加到它正在调用的外部站点的查询字符串中。
JavaScript window.open
函数正在打开一个新窗口,但它将原始网站的 URL 置于外部网站 URL 的开头。
这是我正在使用的 jQuery 代码:
$(function () {
$("#btnTransfer").click(function () {
//custom logic
window.open('http:\\www.google.com');
});
新窗口打开,URL 为:
http://localhost:28761/www.google.com
有什么想法吗?
我尝试使用 _blank
作为名称。
I am using MVC3 and jQuery. I am trying to open an external website. I am using the click event (and not a link) because I have some custom logic that will add values to a query string of the external site it is calling.
The JavaScript window.open
function is opening a new window, however it is pre-pending the original website's URL to the begining of the external website's URL.
Here is the jQuery code I am using:
$(function () {
$("#btnTransfer").click(function () {
//custom logic
window.open('http:\\www.google.com');
});
The new window opens with the URL of:
http://localhost:28761/www.google.com
Any ideas?
I have tried using _blank
as the name.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你的斜杠是向后的:
应该
使用错误的斜杠,它会被解释为相对网址。
Your slashes are backwards:
should be
with the wrong slashes it would be interpreted as a relative url.
你的网址不正确。您需要使用正斜杠而不是反斜杠。
you url is incorrect. You need to use forward slashes not backslashes.