Display Text in Div if IE8 Only

HI EE,

I've been trying to get my webpage to display Text to a div if it detects that the web browser is IE8.

My site is using php 5.4 as well as the jquery 1.11.3

I've tried many different variations with no luck.

Any guidance would be fantastic.

Many Thanks

Ross
LVL 7
Ross TurnerManagement Information Support AnalystAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David H.H.LeeCommented:
Hi Ross,
Try this:

Use this HTML5 to declare your body tag:
<!--[if IE 8]> <body class="ie8"> <![endif]-->

Open in new window


Then use this jQuery/javascript to run any browser specific code:
if($("body").hasClass("ie8")){
   //Do IE 8 specific stuff 
};

Open in new window



OR

if ($.browser.msie  && parseInt($.browser.version, 10) === 8) {
  alert('IE8');
}

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ross TurnerManagement Information Support AnalystAuthor Commented:
Thank  you David H.H.Lee i will test your solutions and i will get back to you as soon as possible.
Ross TurnerManagement Information Support AnalystAuthor Commented:
HI David,

I've tested your solution and it work a charm, thank you so much :)

Ross
David H.H.LeeCommented:
You are welcome, Ross :)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
jQuery

From novice to tech pro — start learning today.