如何使用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)