Solved

Old Browser Popup

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

Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
CSS Scroll Center with Static Side. Like EE does. 2 29
How do use '  ' within this code? 4 28
How do i use the await event in php echo 5 19
boostsrap 1 10
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)

733 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