开发者

jquery IE support for show()

开发者 https://www.devze.com 2022-12-19 06:24 出处:网络
All, I have the following code , <div id=\"show\" display=\"none\"></div> var ele=document.getElementById(\'show\');

All,

I have the following code ,

    <div id="show" display="none"></div>

    var ele=document.getElementById('show');
    ele.style.display='block';
    ele.style.padding='1px';
    ele.style.borderLeft='solid 1px #d0d0d0';
    ele.style.borderBottom='solid 1px #a0a0a0';
    ele.style.position='absolute';
    ele.style.borderTop=开发者_如何学C'solid 1px #d0d0d0';
    ele.style.borderRight='solid 1px #a0a0a0';
    ele.style.backgroundColor='#ffffaa';
    ele.style.fontSize='12px';
    ele.style.fontFamily='helvetica';
    ele.style.color='black';

    $(window).mouseover(function(event) {
     $("#show").css({'top': (event.pageY)/2, 'left': '10px'});
    });

In internet explorer the div does not get displayed could someone please tell me the code change to make it work on IE.

Thanks...................


You haven't called show...

$("#show").show();


First of all you can set all these styles in a css class.

#show { copy all your styles here }

I think if you want o move the div according to the mouse movement then you have to handle mosemove rather than mouseover. Enclose your mousemove function inside document ready event.

$(function(){
    $(window).mousemove(function(event) {
        $("#show").css({'top': (event.pageY)/2, 'left': '10px'});
    });
});

Edit

If you want the div to act as a tooltip then you can write something like this

$("#show").css({'top': event.pageY + 15, 'left': event.pageX + 15});

Check the display style of the div to be block before changing the CSS values.


I think you should take out the following line:

ele.style.display='block';

And then call your jQuery like this:

$("#show").css({'top': 100, 'left': 10}).show();// element gets passed to callback function

You may notice that I gave top a fixed value, just so that you can determine that the element gets displayed AT ALL. If it does, then you can safely say that IE does not get the value of event.pageY. Also, pixel-value css properties are defined like above, if I am correct.


First of all, move CSS to a class

#show {
// put it here
}

Why use javascript when you can do it with CSS? May be IE problem is with that part of JavaScript code.

And your is empty, hell, but how do you want to see an empty div???? Put some text and try again.


          <script type="text/javascript">
                myFlashObject=new Object
                myFlashObject.movie="new_wheel.swf"
                myFlashObject.quality="high"
                myFlashObject.wmode="transparent"
                myFlashObject.width="960px"
                myFlashObject.height="600px"
                myFlashObject.version="6,0,0,0"
                commitFlashObject(myFlashObject, "flash")
          </script>
0

精彩评论

暂无评论...
验证码 换一张
取 消