开发者

Alert the user to open application in IE or fire fox browser

开发者 https://www.devze.com 2023-01-27 04:31 出处:网络
When ever user tries to open an applicationotherthanmozilla(fire fox) orIEbrowser , weneed to alert the user telling 开发者_StackOverflow社区him please open the application inIE or Firefox browser. An

When ever user tries to open an application other than mozilla(fire fox) or IE browser , we need to alert the user telling 开发者_StackOverflow社区him please open the application in IE or Firefox browser. And the browser which he has opened the application should stop and we should not close the browser in which he has opened Ex : like other browser ( google crome, opera )

So first I need to check which browser are they running the application based on that I need to send an alert message.

Any help on this would be greatly appreciated.

thanks


use javascript navigator object to check browser and then alert user..

 <script type="text/javascript">
 document.write("Browser CodeName: " + navigator.appCodeName);
 document.write("<br /><br />");
 document.write("Browser Name: " + navigator.appName);
 document.write("<br /><br />");
 document.write("Browser Version: " + navigator.appVersion);
 document.write("Platform: " + navigator.platform);
 document.write("<br /><br />");
 document.write("User-agent header: " + navigator.userAgent);
 </script>


You cannot do this

Anything you rely on will be supplied by the browser and you cannot trust this.

Anyone can manipulate their browser to lie about who they are, check out User Agent Switcher in firefox

Best sort your site out so that it supports multiple browsers...


Check HttpContext.Current.Request.Browser, see http://msdn.microsoft.com/en-us/library/system.web.httpbrowsercapabilities.aspx


This is the condition to use:

<script>
if ((navigator.appName == "Microsoft Internet Explorer") &&
    (parseInt(navigator.appVersion) >= 4)) {
} else if (window.sidebar) {
} else {
    alert("Please open the site in IE or Firefox");
}
</script>
0

精彩评论

暂无评论...
验证码 换一张
取 消