I tested the following code in IE6, IE7 and IE8 with the same result:
<a name="cd"/>a</a><script>try {cd = new Date;} catch(e) {alert(e);}</script>
In all cases, an error occurs. However using
var cd = new date;
seems to solve the problem.Does anyone know why this is?
Here is an example: http://jsbin.com/ahuhu4/2
var , cd , . window.cd. , <a name="cd">a</a>, . , . var, . IE . -.
window.cd
<a name="cd">a</a>
IE window "id" . . (: .)
window
edit — , "id" . , - IE , "id" . , document.getElementById("cd") <a> , "id" .
document.getElementById("cd")
<a>
edit again , , IE window , , , IE8. , ( "cd" ) , - . IE DOM "id" "name". var, , (, ), "lookup" .
var
// Firefox . IE, # 9, Opera 10, Safari 5 Chrome 6, rollcall id'd .
, ...
function a1(id){ try{ window[id].style.color= 'red'; } catch(er){ return er.message+'\n'+'window.'+id+' = '+window[id]; } return 'window.'+id+'='+window[id]; } function a2(id){ window[id]= 'red'; return 'window.'+id+'='+window[id] }
/*
firefox [idstring] - undefined.
, IE document.all.
(a1 ( 'idstring'))
colors the element red and returns[object HTMLButtonElement] (returns [object Object] in older ie browsers)
: alert (a2 ('idstring')) 'red'
alert (a1 ('idstring'))
- 'window [id].style'
* /
Source: https://habr.com/ru/post/1769364/More articles:Простая проблема с машиной - vhdlДля чего нужен файл конфигурации .NET XML? - .netUsing a dynamic URL to add an image using XSL: FO - xmlHow to choose a column consisting of several column values - sqlSet the graphic url dynamically to the xsl file - variableshttps://translate.googleusercontent.com/translate_c?depth=1&pto=aue&rurl=translate.google.com&sl=ru&sp=nmt4&tl=en&u=https://fooobar.com/questions/1769365/creating-a-local-transparent-cache-of-a-mercurial-repository&usg=ALkJrhjegah_NWeR-ksSgkBQT7jMb1rKxwConfiguring Unity 2.0 Web.config with MVC - asp.net-mvcjava SDK for SIP softphone client - javaChrome Javascript leak search - javascriptHow to get the value of a column, which is defined in another table - sqlAll Articles