0
我有一個ASP頁面,其中JavaScript在IE10(正確)中的行爲與FireFox(最新版本)中的行爲不同。在ASP中的JavaScript與Firefox的行爲在IE中的行爲不同
我有一個隨機顏色生成如下:
// Function to generate random colours
function rgbcolors() {
// rgb string generation
var col = "rgb("
+ Math.floor(Math.random() * 255) + ","
+ Math.floor(Math.random() * 255) + ","
+ Math.floor(Math.random() * 255) + ")";
//change the text color with the new random color
return col;
}
然後我用一個變量來存儲隨機顏色:
var strColor = rgbcolors();
現在,當我使用該顏色別的變量它似乎在FireFox中生成隨機顏色,而不是在變量中存儲的顏色:
strHTML += '<td align="center"><font color="' + strColor + '">'
然後這裏的顏色是不同的:
var pieData = [
{
value: intUsed,
color: strColor
},
奇怪的IE10工作100%,因爲它應該。
感謝您的反饋意見。我會嘗試使用style ='color:...屬性來研究如何將JavaScript的十進制轉換爲十六進制。我其實對JavaScript很少了解。 – user3017424
@ user3017424 - 你可以用'style.color'使用'rgb()'格式。 – jfriend00
優秀,優秀,優秀。謝謝。 – user3017424