遇到 document.getElementById
问题在 IE 11 中检索 div
谁有一个很长的 url 作为 id。
示例:
<div id="http://localhost:8084/group/control_panel/manage?p_auth=2kVqRblu&p_p_id=swcportaluploadData_WAR_swcportaluploadDataportlet&p_p_lifecycle=1&p_p_state=maximized&p_p_mode=view&doAsGroupId=20182&refererPlid=20185&controlPanelCategory=current_site.content&_swcportaluploadData_WAR_swcportaluploadDataportlet_javax.portlet.action=loadCsvData&_swcportaluploadData_WAR_swcportaluploadDataportlet_fileName=CIS_Contact.xlsx"></div>
我得到一个空值,但 id 是唯一的。 在 Google Chrome 上按预期工作。
哪里出了问题?特殊字符?
PS:对于简单的 id 来说效果很好:<div id="hello">
最佳答案
HTML4 不允许使用斜杠,如本定义中所述:
ID and NAME tokens must begin with a letter ([A-Za-z]) and may be followed by any number of letters, digits ([0-9]), hyphens ("-"), underscores ("_"), colons (":"), and periods (".").
IE 仍然执行该标准。
如果您想使用 URL,请将 URL 存储在 data-url
属性中。
关于javascript - 获取元素ById : IE Issues,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36871084/