PDA

View Full Version : How can embed javascript in if-else function



madu
04-29-2010, 07:21 PM
Hello all,
i want to know how the embed javascript in if-else function,
i have tried. but its not working....
what is the wrong with this code ???????????????????????????????????????

<html>
<head>
<!--[ if lte IE ]>

<script type="text/javascript">
<!--
function show_alert()
{
alert("This Is Internet Explorer");
}
//-->
</script>

<!-- [Else]>

// embed java script file
<script src="test.js" type="text/javascript"></script>

<script type="text/javascript">
<!--
function show_alert()
{
alert("This Is Not Internet Explorer");
}
//-->
</script>

<![endif]-->

</head>
<body>
</body>
</html>

bluewalrus
04-29-2010, 08:06 PM
http://msdn.microsoft.com/en-us/library/ms537512%28VS.85%29.aspx

Or



<html>
<head>
<!--[if IE]>
<script type="text/javascript">
<!--
function show_alert()
{
alert("This Is Internet Explorer");
}
//-->
</script>
<![endif]-->

<![if !IE]>
// embed java script file
<script src="test.js" type="text/javascript"></script>

<script type="text/javascript">
<!--
function show_alert()
{
alert("This Is Not Internet Explorer");
}
//-->
</script>
<![endif]>
</head>
<body>
</body>
</html>