Avatar of DColin
DColin
Flag for Thailand asked on

Code does not work with IE

Hi Experts,

Please look at the code below. When a user clicks one of the two fields the field is highlighted with a bold border. It works with Firefox and Chrome but not IE.

<html>
<head>
    <title></title>
    <link href="default.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript">

        function highlightOffer(offerNumber) {

            switch (offerNumber) {
                case 1:
                    document.getElementById('offer1').setAttribute("style", "border-width: 5; border-spacing: 1; border-style: solid; border-color: Green;");
                    document.getElementById('offer2').setAttribute("style", "border-width: 5; border-spacing: 1; border-style: none; border-color: Green;");
                    break;
                case 2:
                    document.getElementById('offer1').setAttribute("style", "border-width: 5; border-spacing: 1; border-style: none; border-color: Green;");
                    document.getElementById('offer2').setAttribute("style", "border-width: 5; border-spacing: 1; border-style: solid; border-color: Green;");
                    break;
 
            }

        }

    </script>
</head>
<body>
    <center>
        <table width="1000">
            <tr>
                <td width="25%">
                    <table onclick="javascript:highlightOffer(1);" id="offer1" style="border-width: 5;
                        border-spacing: 1; border-style: none; border-color: Green;" width="100%">
                        <tr>
                            <td align="center" style="border-width: 1; border-style: solid; border-color: Green;"
                                bgcolor="White">
                                <br />
                                <h2>
                                    1 Title</h2>
                                <br />
                            </td>
                        </tr>
                    </table>
                </td>
                <td width="25%">
                    <table onclick="javascript:highlightOffer(2);" id="offer2" style="border-width: 5;
                        border-spacing: 1; border-style: solid; border-color: Green;" width="100%">
                        <tr>
                            <td align="center" style="border-width: 1; border-style: solid; border-color: Green;"
                                bgcolor="White">
                                <br />
                                <h2>
                                    2 Title</h2>
                                <br />
                            </td>
                        </tr>
                    </table>
                </td>      
            </tr>
        </table>
        <br />
    </center>
</body>
</html>
HTMLJavaScript

Avatar of undefined
Last Comment
Francisco Igor

8/22/2022 - Mon
Gurvinder Pal Singh

try cleaning up the code a bit. Rather than assigning the attributes one by one using JavaScript, assign a different class to the element
IanTh

/mcrosoft are going to silently updating ie without warning so in future for code to work in ie it needs to be exeptionally clean so you dont have to fix it for each new version
I would suggest getting into html5 as thats what is going to work with ie I think
ASKER CERTIFIED SOLUTION
Francisco Igor

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck