Javascript in Xhtml editor

Per Nergård
Member since: 2007

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

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

    /Good luck


    (Editreason: remove junk code... Surprised)

    #26690 Edited, Dec 16, 2008 11:37