如何检测客户端pc使用的浏览器 [英] how to detect browser using by client pc
本文介绍了如何检测客户端pc使用的浏览器的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
i想询问如何检测用户用来浏览我的网页的浏览器名称?因为我希望他们只使用Firefox ..如果他们是使用IE @ Chrome我想阻止他们查看。这是因为系统包含一个打印过程,他们不想要打印对话框。我发现解决方案的唯一方法就是使用firefox浏览器。
所以我想首先得到浏览器名称,如果ie @ chrome我想阻止,如果firefox然后继续打开网页。
谢谢,
musiw。
i want to ask on how to detect browser name that user use to browse my webpage?because i want they use Firefox only..if they are using IE@Chrome i want to block them from viewing.this is because the system is include a print process and they dont want a print dialog.the only way i found the solution is using firefox browser.
so i want to get the browser name first so that if ie@chrome i want to block and if firefox then continue to open the web page.
thanks,
musiw.
推荐答案
使用Request.UserAgent属性可以检测下面的浏览器类型是示例代码
if(Request.UserAgent.ToLower()。IndexOf(firefox)!= -1)然后
Else
结束如果
Using Request.UserAgent property you can detect browser type below is the sample code
if (Request.UserAgent.ToLower().IndexOf("firefox") != -1) then
Else
End If
要简短:忘掉它。
你的意图有点奇怪。
尽管如此,在服务器端你必须要相关y客户端发送的数据,更确切地说是用户代理 [ ^ ]标题属性。但是可以轻松地在客户端进行更改:只有用户可以用来更改此属性的所有浏览器的插件,例如: http://www.gtricks.com/google-chrome-tricks/change-user-agent-string/ [ ^ ]
To be short: forget it.
Your intention is somewhat strange.
Still, on server side you have to relay on the data sent by the client, more precisely the User Agent[^] header property. But that can be altered on client side with ease: there are plugins for merely all browsers that users can use to change this property, look at this one for example: http://www.gtricks.com/google-chrome-tricks/change-user-agent-string/[^]
你可以使用javascript或C#。
参考以下链接:
Javascript:
- 使用导航器对象检测客户端的浏览器 [ ^ ]
- 使用JavaScript检测浏览器名称 [ ^ ]
- 您还应该检查: javascript中的浏览器检测? [ ^ ]
You can do it using javascript or C#.
Refer the links below:
Javascript:
- Using the navigator object to detect client''s browser[^]
- Browser Name Detection using JavaScript[^]
- Also you should check : Browser detection in javascript?[^]
- 代码:检测浏览器版本(Visual C#) [ ^ ]
- 如何:检测ASP.NET网页中的浏览器类型和浏览器功能 [ ^ ]
- 使用ASP.NET和C#检测浏览器 [ ^ ]
- Code: Detecting the Browser Version (Visual C#)[^]
- How to: Detect Browser Types and Browser Capabilities in ASP.NET Web Pages[^]
- Detect the browser using ASP.NET and C#[^]
这篇关于如何检测客户端pc使用的浏览器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文