Try our conversational search powered by Generative AI!

Javascript in Xhtml editor

Vote:
 

I tried to add a web surve consisting of a div and some javascripts to the html mode of a xhtml editor.

The div looks ok in edit mode but when I view the page I get a javascript error.

 The script code must be added directly below the div, and the javascript is read from a url.

The message i get is getElemenbtby(...) is null or somthing like that. I thougt this should work. Not the easist question to answer whats wrong but a few tips would be greatly appreciated.

#26488
Dec 08, 2008 17:23
Vote:
 

Hi Per!

I did a test myself and got the following to work without problem. The div with id foo turns up red as expected. The js error message indicates you have not used the correct id when trying to find the element (the element can't be found and hence is null)... 

<DIV id=foo>Yada yada</DIV>
<SCRIPT type=text/javascript>
document.getElementById("foo").style.backgroundColor = "red";
</SCRIPT> 

/Good luck

Henrik

(Editreason: remove junk code... Surprised)

#26690
Edited, Dec 16, 2008 11:37
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.