Solved

Old Browser Popup

Posted on 2014-07-23
12
276 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 109

Expert Comment

by:Ray Paseur
ID: 40215581
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 109

Expert Comment

by:Ray Paseur
ID: 40215584
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
ID: 40215588
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
Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 
LVL 58

Expert Comment

by:Gary
ID: 40215797
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 109

Expert Comment

by:Ray Paseur
ID: 40215911
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
ID: 40217128
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
 
LVL 58

Expert Comment

by:Gary
ID: 40217144
0
 
LVL 11

Author Comment

by:N R
ID: 40217145
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
ID: 40217158
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
ID: 40217176
Updated code, also called it on document ready, but still not getting the alert.
0
 
LVL 58

Expert Comment

by:Gary
ID: 40217201
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
ID: 40217205
Yeah just got the popup, working now thanks!
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Introduction This article is intended for those who are new to PHP error handling (https://www.experts-exchange.com/articles/11769/And-by-the-way-I-am-New-to-PHP.html).  It addresses one of the most common problems that plague beginning PHP develop…
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…
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

813 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

16 Experts available now in Live!

Get 1:1 Help Now