2011-03-18 76 views
1

我正在研究這些富媒體廣告的工作,他們在所有瀏覽器中工作,直到我開始使用jQuery css方法。 IE中沒有任何內容顯示,昨天我參加會議時這不是問題。我可能鏈接到的唯一可能是IE處理css的方式不同。任何幫助將不勝感激,這裏是我的代碼示例。Firefox和IE如何處理jQuery CSS有什麼區別?

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
<html xmlns="http://www.w3.org/1999/xhtml"> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> 
<title>Molson Canadian Ad Template</title> 

<style type="text/css"> 

body { 
    background-color: #333; 
} 

</style> 

<script src="http://code.jquery.com/jquery-1.5.js"></script> 
<script src="jquery.swfobject.1-1-1.min.js" type="text/javascript"></script> 

<script> 

$(document).ready(

    function() { 

     jsReady = true; 

     banner1 = $('#banner1'); 
     banner1.css({overflow:'hidden', position:'absolute', left:158}); 
     banner1.flash({swf: 'molson1_300x250.swf', width: 300, height: 250, play: true, flashvars: {message:'in'}}); 
    } 
); 

var jsReady = false; 

function isReady() { 

    return jsReady; 
} 

function sendToJavaScript(value) { 

    if(value == "expand"){ 

     banner1.css('left', 0); 
     banner1.flash().remove(); 
     banner1.flash({swf:'molson1_600x250.swf', width:600, height:250, wmode:"transparent"}); 

    }else{ 

     banner1.css('left', 158); 
     banner1.flash().remove(); 
     banner1.flash({swf: 'molson1_300x250.swf',width: 300,height: 250,play: true},function(){this.GotoFrame(71)}); 
    } 
} 

</script> 

</head> 

<body> 
<div id="banner1"></div> 
</body> 
</html> 
+0

到底是什麼錯呢? – 2011-03-18 16:25:33

回答

0

是否有怎樣的Firefox 和IE手柄jQuery的CSS區別嗎?

是的。

這一切都知道:

http://www.quirksmode.org/css/contents.html

1. IE 5/6 doesn’t implement overflow: visible correctly. 
2. E 5/6 don’t support position: fixed 
    IE7 has a strange bug; see page. 
+0

我其實認爲這個問題的主要目的不在於是否存在任何差異,而是爲什麼這個特定的例子工作不同。 – anothershrubery 2011-03-18 16:24:43

+0

是的,我的建議是閱讀發佈的文章,並專門檢查我從文章中引用的兩個CSS屬性,因爲它們在IE中有問題。 – slandau 2011-03-18 16:26:00

+0

我在評論後編輯過!公平的...... – anothershrubery 2011-03-18 16:31:29

1

我琢磨出來的傢伙,我是有這個問題是我會定義一個變量,像這樣

banner1 = $('#banner1'); 

,然後嘗試打電話給這樣的方法

banner1.css(); 

這工作正常在Firefox,但在IE中你必須調用它像這樣

$('#banner1').css(); 
+0

你提到的改變通常不會有什麼區別,但我想冒一個猜測。如果使用'var banner1 = $('#banner1');'會發生什麼?我問的原因是因爲IE瀏覽器自動將ID作爲全局變量在JavaScript中可用(即默認情況下,js中的'banner1'可以使用'id =「banner1」'的元素),它可能是,因爲你是基本上試圖覆蓋這個預先存在的變量'banner1',它失敗了..只是一個猜測。 – Pebbl 2013-07-27 08:25:18

相關問題