Results 1 to 2 of 2

Thread: How can embed javascript in if-else function

  1. #1
    Join Date
    Apr 2010
    Posts
    40
    Thanks
    13
    Thanked 0 Times in 0 Posts

    Default How can embed javascript in if-else function

    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>

  2. #2
    Join Date
    May 2007
    Location
    Boston,ma
    Posts
    2,127
    Thanks
    173
    Thanked 207 Times in 205 Posts

    Default

    http://msdn.microsoft.com/en-us/libr...8VS.85%29.aspx

    Or

    Code:
    <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>
    Corrections to my coding/thoughts welcome.

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •