small javascript problem
I have this little function that opens modal window type thing. The problem is that it doesnt work on IE. All other browser its fine, but on IE, nothing happends:
function showOverlayBox() {
if( isOpen == false ) return;
$('#full').css({
display:'block',
left: ( $(window).width() - $('#full').width() )/2,
top: ( $(window).height() - $('#full').height() )/2,
position:'absolute'
});
$('.BgCover').css({
display:'block',
width: $(window).width(),
height: $(window).height()
});
}
function doOverlayOpen() {
isOpen = true;
showOverlayBox();
$('.BgCover').css({opacity:0}).animate( {opacity:0.8} );
return false;
}
function doOverlayClose() {
$('#full').css( 'display', 'none' );
$('.BgCover').animate( {opacity:0}, null, null, function() { $(this).hide(); } );
}
Maybe something to do with isOpen == f开发者_开发知识库alse?
I have pasted your code into this HTML snippet:
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
</head>
<body>
<div class="BgCover" style="background-color: red; display:none"></div>
<div id="full" style="display:none; background-color: yellow">Hello!</div>
<script type="text/javascript">
<!-- Your code here -->
$("<span>Do it</span>").click(doOverlayOpen).insertAfter($("#full"));
</script>
</body>
</html>
This works as expected in Firefox and in IE7. So there must be something in the part you didn't show us. One idea: Are you sure BgCover
is (and / or should be) a class
in your HTML, and not the id
?
精彩评论