Solved

Old Browser Popup

Posted on 2014-07-23
12
273 Views
Last Modified: 2014-07-25
Is there a way to check if a user is using a version of internet explorer older than version 10 and show them a popup that they need to update to best view the site?

Attached is an example.
asdf.jpg
0
Comment
Question by:N R
  • 4
  • 4
  • 3
  • +1
12 Comments
 
LVL 108

Expert Comment

by:Ray Paseur
Comment Utility
Sure.  You can detect the client browser in PHP with the $_SERVER["HTTP_USER_AGENT"] variable.  Here is what mine says:

Mozilla/5.0 (Windows NT 6.1; rv:30.0) Gecko/20100101 Firefox/30.0
0
 
LVL 108

Expert Comment

by:Ray Paseur
Comment Utility
And in their HTML page source, there is this:
<!--[if lte IE 8]><div id="overflowIE" style="z-index:2000;position:fixed;top:0px;left:0px;width:100%;height:100%;background-image:url(http://guruenergy.com/media/images/bg_b70.png);overflow:hidden;">
<div id="iewarning"><h1>Please update your browser for a better experience.</h1>
<p>(And maybe crack up a Guru while it's being done).</p>
<table cellpadding="0" cellspacing="0" border="0">
	<tr>
		<td><a href="http://www.mozilla.org/en-US/products/download.html" target="_blank"><img alt="Firefox" src="/media/images/browsers/firefox.png"/><br/><span>Firefox</span></a><td>
		<td><a href="http://www.google.com/chrome‎" target="_blank"><img alt="Chrome" src="/media/images/browsers/chrome.png"/><br/><span>Chrome</span></a><td>
		<td><a href="http://www.opera.com/download/‎" target="_blank"><img alt="Opera" src="/media/images/browsers/opera.png"/><br/><span>Opera</span></a><td>
		<td><a href="http://support.apple.com/downloads/#safari" target="_blank"><img alt="Safari" src="/media/images/browsers/safari.png"/><br/><span>Safari</span></a><td>
		<td><a href="http://www.microsoft.com/fr-ca/download/details.aspx?id=40902" target="_blank"><img alt="Internet Explorer" src="/media/images/browsers/ie.png"/><br/><span>Internet<br>Explorer</span></a><td>
	</tr>
</table></div></div><![endif]-->

Open in new window

0
 
LVL 21

Accepted Solution

by:
Randy Poole earned 500 total points
Comment Utility
A simple way in JS, just call the following function:
function checkbrowser() 
{
        var ua = window.navigator.userAgent;
        var msie = ua.indexOf("MSIE ");
        var ver=0;
        if (msie > 0) ver=parseInt(ua.substring(msie + 5, ua.indexOf(".", msie))));
        if (ver<10 && ver>0) alert('Please upgrade your browser');
}

Open in new window

0
 
LVL 58

Expert Comment

by:Gary
Comment Utility
Randy's comment is the only correct solution
IE11 removed the MSIE flag in the user agent string and Randy's code correctly identifies less than IE10 - though IE9 wasn't all that bad...

(no points for this - just pointing out the correct solution vs the junk and the reason why)
0
 
LVL 108

Expert Comment

by:Ray Paseur
Comment Utility
If the example you posted is what you want, then the cut-paste from the example web page shows the design pattern that was used to create the popup window you saw in the example.  As usual with most computer programming projects, there are many ways to find a solution.

Best to all, over and out, ~Ray
0
 
LVL 11

Author Comment

by:N R
Comment Utility
Great thanks guys, how can I test this?  I have IE 11 so is there a website or anything to test web pages as IE 8 or 9?
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 58

Expert Comment

by:Gary
Comment Utility
0
 
LVL 11

Author Comment

by:N R
Comment Utility
I'm trying to use the IE dev tools to change it to IE 8 & 9, but not getting the popup.  I added the code to the page however.

http://alwaysvanilla.com/
0
 
LVL 58

Expert Comment

by:Gary
Comment Utility
Randys code has an extra ) at the end

if (msie > 0) ver=parseInt(ua.substring(msie + 5, ua.indexOf(".", msie))));

...and you need to actually call the function.
0
 
LVL 11

Author Comment

by:N R
Comment Utility
Updated code, also called it on document ready, but still not getting the alert.
0
 
LVL 58

Expert Comment

by:Gary
Comment Utility
Working fine for me in Dev Tools for IE9 and lower.
Be sure to do an hard refresh
0
 
LVL 11

Author Comment

by:N R
Comment Utility
Yeah just got the popup, working now thanks!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

So you have coded your own WordPress plugin and now you want to allow users to upload images to a folder in the plugin folder rather than the default media location? Follow along and this article will show you how to do just that!
CSS is a visual language used to classify objects and define rules about how they should be displayed. CSS skills aren’t restricted to developers anymore, there is a big benefit to having a basic understanding of the language, regardless of your occ…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now