1

Having a problem with document.getElementById in IE 11 to retrive a div who has a long url as id.

Example :

<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>

I am getting a null, but the id is unique. Works as expected on Google Chrome.

Where is the fault ? Special characters?

PS: It works fine for a simple id : <div id="hello">

joey rohan
  • 3,505
  • 5
  • 33
  • 70

1 Answers1

1

HTML4 doesn't allow slashed as mentioned in this definition:

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 still enforces that standard.

If you want to use the url, rather store the url in a data-url attribute.

Barry Michael Doyle
  • 9,333
  • 30
  • 83
  • 143