Solved

Old Browser Popup

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

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
 
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 108

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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Introduction If you're like most people, you have occasionally made a typographical error when you're entering information into an online form.  And to your consternation, the browser remembers the error, and offers to autocomplete your future entr…
Building a website can seem like a daunting task to the uninitiated but it really only requires knowledge of two basic languages: HTML and CSS.
In this tutorial viewers will learn how to style different bullet points for unordered lists in CSS. Begin with a normal unordered list; the default bullet point is a solid circle: In the CSS, create a defined class of unordered list by typing "ul.S…
In this tutorial viewers will learn how to embed custom externally-hosted Google Fonts using the Google Font API in CSS Go to the Google Fonts website at google.com/fonts: Browse or search based on font properties or name to find a suitable font for…

896 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

12 Experts available now in Live!

Get 1:1 Help Now