Solved

Old Browser Popup

Posted on 2014-07-23
12
288 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 4
  • 3
  • +1
12 Comments
 
LVL 110

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 110

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
Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

 
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 110

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

Secure Your WordPress Site: 5 Essential Approaches

WordPress is the web's most popular CMS, but its dominance also makes it a target for attackers. Our eBook will show you how to:

Prevent costly exploits of core and plugin vulnerabilities
Repel automated attacks
Lock down your dashboard, secure your code, and protect your users

Question has a verified solution.

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

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…
Since pre-biblical times, humans have sought ways to keep secrets, and share the secrets selectively.  This article explores the ways PHP can be used to hide and encrypt information.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

729 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