Connecting Tech Pros Worldwide Help | Site Map

DOM image load problem

  #1  
Old August 29th, 2008, 01:04 PM
Newbie
 
Join Date: Aug 2007
Posts: 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?
  #2  
Old August 30th, 2008, 03:32 PM
gits's Avatar
Moderator
 
Join Date: May 2007
Location: Munich, Germany
Posts: 4,102
Provided Answers: 1

re: DOM image load problem


try the following instead of using setAttribute:

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Image map problem Andy Baxter answers 3 June 1st, 2006 01:25 AM
Problem accessing DOM of window.open result DOM_scripter answers 2 March 5th, 2006 08:15 PM
Image rotation and dimensions John answers 1 July 23rd, 2005 12:35 PM