2012-02-15 31 views
1

這段代碼適用於除firefox之外的所有主流瀏覽器,它說它已經完成了我所要求的,但事實並非如此。這讓我瘋狂。這是一個完整的HTML,CSS和JavaScript:firefox不尊重JavaScript漂移方向的變化

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" > 
<html> 
<head> 
<style type=text/css> 
.CastPic 
{ 
    position  : relative; 
    top  : +0px; 
    width  : 250px; 
    height : 250px; 
    padding-top  : 25px; 
    padding-left  : 25px; 
    padding-right  : 25px; 
    padding-bottom  : 25px; 
    background-image  : url('Cast photos/Fiona Colquhoun.jpg'); 
    background-color  : ivory; 
    background-repeat  : no-repeat; 
    background-position  : center; 
    cursor   : pointer; 
    border-style  : solid; 
    border-width  : 12px; 
    border-color  : green; 
    float   : left; 
} 
</style> 
<script language="JavaScript" type="text/JavaScript"> 
function toggle() 
{ 
if (document.getElementById("CastPic").style.float =="right") 
{ 
    document.myForm.msg.value = "float is right" 
    document.getElementById("CastPic").style.float="left" 
    document.getElementById("CastPic").style.borderColor="red" 
} 
else 
{ 
    document.myForm.msg.value = "float is left" 
    document.getElementById("CastPic").style.float="right" 
    document.getElementById("CastPic").style.borderColor="blue" 
} 
document.myForm.msg.value = 'float is now ' + document.getElementById("CastPic").style.float 
} 
</script> 
</head> 
<body> 
<div class="CastPic" id="CastPic"></div> 
<form name="myForm" enctype="application/x-www-form-urlencoded"> 
<input type="text" name="msg" value="" size=65> 
<input type="button" value="Switch" onClick="toggle()"> 
</form> 
</body> 
</html> 

這當然只是一個測試腳本 - 我提取該位只是爲了看看別的影響它。我什麼也看不見。

蒂亞 阿德里安

+0

您的代碼在Opera中無法正常工作。它只適用於Chrome和Safari,因爲https://bugs.webkit.org/show_bug.cgi?id=77427 – 2012-02-15 19:56:51

回答