如何使用jQuery打开新窗口? [英] How do I open a new window using jQuery?

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

问题描述

我有以下两种建议.

window.location.href = '/Administration/Notes/Create?dsValue=a&selectAnswer=b';
$.get("/Administration/Notes/Create", { dsValue: dsValue, selectedAnswer: answer });

这些方法是否相同?哪一个最适合我使用,两者之间有什么区别?

Are these methods the same? Which one would be the best for me to use and what's the difference between the two?

推荐答案

这些绝不是相同的.第一个将简单地将您发送到您分配给window.location.href的任何URL(在您当前所在的同一窗口中).第二个发出GET AJAX请求.

Those are by no means the same. The first will simply send you to whatever URL you have assigned to window.location.href (in the same window you're currently in). The second makes a GET AJAX request.

尝试此页面: http://www.codebelt.com/jquery/open-new-browser-window-with-jquery-custom-size/

它为如何打开新窗口提供了一个很好的例子*.

It gives a great example on how to open a new window*.

如果您希望使用原始javascript,那么您正在寻找的是

If you wish to use raw javascript then this is what you're looking for:

window.open(URL,name,specs,replace)

http://www.w3schools.com/jsref/met_win_open.asp

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

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