By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,968 Members | 1,458 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,968 IT Pros & Developers. It's quick & easy.

DOM image load problem

P: 10
My Javascript looks like this:
Expand|Select|Wrap|Line Numbers
  1. var myObject = document.createElement("div");
  2. myObject.setAttribute("class", "myclass");
  3. myObject.appendChild(document.createTextNode("The content to go in the myObject DIV"));
My class looks like this:
Expand|Select|Wrap|Line Numbers
  1. .myclass
  2. {
  3.     margin-left:20px;
  4.     margin-right:20px;
  5.     width:200px;
  6.     height:200px;
  7.     background:url(objectbg.png) repeat-y left top;
  8. }
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?
Aug 29 '08 #1
Share this Question
Share on Google+
1 Reply

Expert Mod 5K+
P: 5,390
try the following instead of using setAttribute:

Expand|Select|Wrap|Line Numbers
  1. myObject.className = 'myclass';
kind regards
Aug 30 '08 #2

Post your reply

Sign in to post your reply or Sign up for a free account.