Connecting Tech Pros Worldwide Help | Site Map
Reply
 
LinkBack Thread Tools Search this Thread
  #1  
Old August 29th, 2008, 01:04 PM
Newbie
 
Join Date: Aug 2007
Posts: 10
Default DOM image load problem

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?
Reply
  #2  
Old August 30th, 2008, 03:32 PM
gits's Avatar
Moderator
 
Join Date: May 2007
Location: Munich, Germany
Age: 36
Posts: 3,448
Default

try the following instead of using setAttribute:

Expand|Select|Wrap|Line Numbers
  1. myObject.className = 'myclass';
kind regards
Reply
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 205,248 network members.