IE和FF中的新标签,但Chrome中的新窗口 [英] new tab in IE and FF, but new windows in Chrome
本文介绍了IE和FF中的新标签,但Chrome中的新窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我做了很多研究和方法,其中没有一个是完美的,但至少下面的代码几乎达到我的目标,我需要浏览器通过使用后面的代码打开新选项卡。
i did a lot of researches and methods, none of them is perfect, but at least the code below almost meet my goal, i need the browser to open the new tab by using code behind.
Response.Write("<script>window.open('http://www.google.com');</script>");
以上代码在IE中打开新标签和FF,但如果用户使用谷歌浏览器,它会打开新窗口。
我该怎么做才能让谷歌打开新标签?
code above open new tab in IE and FF, but it open new windows if user using google chrome.
what should i do to make the google to open the new tab as well?
推荐答案
很遗憾你不能。
在IE中,这是默认操作,在FireFox中,这是用户可以更改的设置。但是在Chrome中,这不是用户可以控制的任何内容,因此它执行规范所说的内容并打开一个新窗口。
Unfortunately you can't.
In IE this is the default action and in FireFox this is a setting that the user can change. However in Chrome this is not anything the user has control over, so it does what the spec says and opens a new window.
请参阅Ron Beyer对解决方案1的评论。
在这种情况下,我认为我们合理地向您解释,最好避免使用window.open
。显然,在创建新标签页或新的单独浏览器窗口之间进行选择时,您几乎不能期望不同浏览器(甚至是开发的同一浏览器的不同版本)的一致行为,这种不一致将严重影响导航用户的体验,尤其是经验最少的用户。此外,弹出窗口是邪恶的。从概念上讲,从Web应用程序的角度来看,创建一个新的标签页仍然是一个弹出窗口。
最好的UI设计应该决定创建一个新标签页面或用户的新单独浏览器窗口,在点击锚点时。
我建议使用替代方法。这是一个很好的选择:
http://jqueryui.com/dialog/ [ ^ ]。
你可以找到很多第三方jQuery插件来实现更复杂(但完全由您的应用程序定义)模仿模态或弹出行为。
-SA
Please see my comments to the Solution 1 by Ron Beyer.
In this situation, which I think we reasonably explained to you, it's the best to avoid usingwindow.open
. Apparently, you hardly can expect consistent behavior of different browsers (and even different versions of the same browser as they are developed) in respect to choice between creation of a new tab page or a new separate browser window, and this inconsistency will badly effect navigation experience of the users, especially the least experienced ones. Besides, pop-ups are evil. Conceptually, from the stand point of a Web application, creating a new tab page is still a popup.
The best UI design should leave the decision to create a new tab page or a new separate browser window to the user, at the moment of clicking on an anchor.
I would advise to use the alternative approach. This is one of the good alternatives:
http://jqueryui.com/dialog/[^].
You can find a lot of 3rd-party jQuery plug-ins to implement more sophisticated (but fully defined by your application) imitation of modal or popup behavior.
—SA
试试这个
Try this
// open in default browser
Process.Start("http://www.csharpdeveloping.net");
// open in Internet Explorer
Process.Start("iexplore", @"http://www.csharpdeveloping.net/");
// open in Firefox
Process.Start("firefox", @"http://www.csharpdeveloping.net/");
// open in Google Chrome
Process.Start("chrome", @"http://www.csharpdeveloping.net/");
快乐编码:)
Happy Coding :)
这篇关于IE和FF中的新标签,但Chrome中的新窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文