问题描述:

thanks for reading.

I have a simple problem that i can't solve. I just need to have a html map with Jquery fadeIn and fadeOut effects. I got it and it works everywhere except with IE8.

So i just wanna add a pure javascript already tested and working just when IE8 is present.

Obviously i tried writing this code but is not working even with a simple alert after the IE comment.

Can you help please?

Here's the code, thanks!

<script type="text/javascript">var runFancy = true;</script>

<!--[if IE]>

<script type="text/javascript">

runFancy = false;

alert(runFancy);

function showIt(name)

{

document.getElementById('map_image').src='immagini/distributori/8/'.concat(name).concat('.png');

document.getElementById('map_image').style.display='block';

}

function hideIt()

{

document.getElementById('map_image').src='immagini/distributori/8/map.png';

};

</script>

<![endif]-->

Here's the code for other browsers

 <!--[if !IE]><!-->

<script type="text/javascript">

//alert('hi'); not working even just this

if (runFancy) {

function showIt(name)

{

document.getElementById('map_image').src='immagini/distributori/single/'.concat(name).concat('_single.png');

$('#mapon').fadeIn(400);

}

function hideIt()

{

$('#mapon').fadeOut(300);

};

}

</script>

<!--<![endif]-->

even this is not working, any advice?

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">

<html>

<head>

<meta http-equiv="Content-Type" content="text/html; charset=utf-8">

<title>Untitled Document</title>

</head>

<body style="background-color:red">

<h1>Ciao</h1>

<!--[if IE]>

<style language="text/css">

body{background-color:black;}

</style>

<![endif]-->

</body>

</html>

not working with every IE version.

网友答案:

This will help you:

HTML:

<!doctype html>
<!--[if IE]><![endif]-->
<!--[if lt IE 7 ]> <html lang="en" class="ie6">    <![endif]-->
<!--[if IE 8 ]>    <html lang="en" class="ie8">    <![endif]-->
<!--[if IE 9 ]>    <html lang="en" class="ie9">    <![endif]-->
<!--[if (gt IE 9)|!(IE)]><!--><html lang="en"><!--<![endif]-->
    <head></head>
    <body></body>
</html>

Javascript:

<!--[if IE 8]>
<script type="text/javascript" src="IE8.js">
<![endif]-->
网友答案:

the code you have should be working but if you want to target just IE 8 put IE 8 instead of just IE like so

<!--[if IE 8]>
do stuff
<![endif]-->

edit: removed depreciated jquery solution

相关阅读:
Top