Monday, 15 March 2010

javascript - Why is this JS not being properly executed in IE? -


This works in the all browser, but IE has censored the code that I < Em> address can read properly, so you are not overwhelmed Why does IE say that my function is not present?

Error:

  SCRIPT5009: 'switchstyle' undefined test.php, line 180 characters 21   

HTML:

  025: & lt; SCRIPT TYPE = "text / JavaScript" SRC = "/ _JS / StyleSwitch 2.js" & gt; & Lt ;! - Style script switching - & gt; & Lt; / SCRIPT & gt; ... 180: & lt; SELECT ONCHANGE = "return switchstyle (this);" & Gt; 181: & lt; OPTION VALUE = "/_ssss / default.css" & gt; Choose a style! & Lt; / OPTION & gt; 182: & lt; OPTGROUP label = "skin group 1" & gt; 183: & lt; OPTION VALUE = "/_css / alt1-1.css" & gt; Alt 1.1 & lt; / OPTION & gt; 184: option option = "/_css / alt1-2.css" & gt; Alt 1.2 & lt; / OPTION & gt; 185: Option Option = "/_ssss/ alt1-3.css" & gt; Alt 1.3 & lt; / OPTION & gt; 186: & lt; / OPTGROUP & gt; 187: & lt; OPTGROUP label = "skin group 1" & gt; 188: & lt; OPTION VALUE = "/_css / alt2-1.css" & gt; Alt 2.1 & lt; / OPTION & gt; 18 9: & lt; OPTION VALUE = "/_css / alt2-2.css" & gt; Alt 2.2 & lt; / OPTION & gt; 190: & lt; / OPTGROUP & gt; 191: & lt; / SELECT & gt;   

JS:

  var sheet element = document.getElementById ("_ switchSheet"); Var backupSheetElement = document.getElementById ("_ switchSheetBackup"); SheetElement.disabled = false; If (backupSheetElement) backupSheetElement.disabled = false; Else // Use the Warning var cookie = true; Const COOKIE_NAME = "cookieame"; Function Switch Style (Selection Element) {If (Sheet Element == blank & amp; amp; amp; amp; & amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; amp; _ Switchsheet ")) == faucet // Failure switch style (selection element value); } Function switch: stylo (new sheet) {sheetElement.href = (new sheet == backupSheetElement.href)? Tap: new sheet; Setcookie (newSheet); } Set functionsUse cookies (shouldcookies) {usecookies = keysecurity; } Function set cookie {cookie} {// works} function getCookie () {// works} function setSatilFrenchKookie () {var cookie = getCookie (); If (cookie.length & gt; 0) switch style (cookie); Else // fail}    

Because this line is an error in IE, restraining the rest By running code.

  const COOKIE_NAME = "cookiename"; Change   

const to var

or:

  Try {Const. COOKIE_NAME = "Cucknim"); } Hold (e) {var COOKIE_NAME = "cookieame"; }    

No comments:

Post a Comment