DOM image load problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • woody79
    New Member
    • Aug 2007
    • 10

    DOM image load problem

    My Javascript looks like this:
    Code:
    var myObject = document.createElement("div");
    myObject.setAttribute("class", "myclass");
    myObject.appendChild(document.createTextNode("The content to go in the myObject DIV"));
    My class looks like this:
    Code:
    .myclass
    {
    	margin-left:20px;
    	margin-right:20px;
    	width:200px;
    	height:200px;
    	background:url(objectbg.png) repeat-y left top;
    }
    My problem is that the background image doesn't load. I have checked the Page Info in Firefox and objectbg.png does not exist in the media list.
    What can I do to fix this?
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5390

    #2
    try the following instead of using setAttribute:

    [CODE=javascript]myObject.classN ame = 'myclass';[/CODE]
    kind regards

    Comment

    Working...