문제

I have the following script:

<!--[if IE]>
    <script type="text/javascript">
    $(document).ready(function () {
    alert("ie");
    $('#usa').mapster({
        fillOpacity: 0.1,
        render_highlight: {
            fillColor: '2aff00',
            stroke: false,
            altImage: 'theImages/skillsets.png'
        },
        render_select: {
            fillColor: 'ff000c',
            stroke: false,
            altImage: 'theImages/skillsets.png'
        },
        fadeInterval: 50
    });
    });
    </script>
    <![endif]-->
    <script>
    $(document).ready(function () {
    $('#usa').mapster({
        fillOpacity: 0.1,
        render_highlight: {
            fillColor: '2aff00',
            stroke: false,
            altImage: 'theImages/skillsets.png'
        },
        render_select: {
            fillColor: 'ff000c',
            stroke: false,
            altImage: 'theImages/skillsets.png'
        },
        fadeInterval: 50
    });
    });
    </script>

If the browser is anything other than IE the second script should fire off, but if it's IE the first script should fire off. Although I see the alert statement fire but the rest of the script is being used from the second javascript.

The only issue is because,

fillOpacity: 0.1

I want it to be 0.1 in IE but 0.9 in other browsers.

도움이 되었습니까?

해결책

Looks like you are still firing the base code after the IE code. If all you wish to change is the opacity then do this:

<script type="text/javascript">
opacity = 0.9;
</script>
<!--[if IE]>
<script type="text/javascript">
opacity =  0.1;
</script>
<![endif]-->

<script>
    $(document).ready(function () {
    $('#usa').mapster({
        fillOpacity: opacity,
        render_highlight: {
            fillColor: '2aff00',
            stroke: false,
            altImage: 'theImages/skillsets.png'
        },
        render_select: {
            fillColor: 'ff000c',
            stroke: false,
            altImage: 'theImages/skillsets.png'
        },
        fadeInterval: 50
    });
    });
    </script>
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top