JavaScript入門篇4-1函數(shù)命名問題,reset()無法實(shí)現(xiàn)
大家好,請(qǐng)問函數(shù)名為reset() 時(shí), 以下程序無法實(shí)現(xiàn), 修改為其他函數(shù)名后可實(shí)現(xiàn),是什么原因?qū)е碌模恐x謝~
function reset() {
? ? ? ? var conf = confirm("Reset the style?");
? ? ? ? if (conf == true) {
? ? ? ? ? ? myHeader.removeAttribute("style");
? ? ? ? ? ? myTxt.removeAttribute("style"); ??
? ? ? ? } else {
? ? ? ? ? ??
? ? ? ? }
? ? }
2015-10-03
reset 是Windows 保留關(guān)鍵字
JavaScript 可以在 HTML 外部使用。它可在許多其他應(yīng)用程序中作為編程語(yǔ)言使用。
在 HTML 中,您必須(為了可移植性,您也應(yīng)該這么做)避免使用 HTML 和 Windows 對(duì)象和屬性的名稱作為 Javascript 的變量及函數(shù)名。否則會(huì)出錯(cuò).
總而言之,其理由就像你不能用return作為函數(shù)名一樣。