Internet Advertising | Loans | eBay | Loan | Advertising
Javascript Question [Archive] - PCMech Forums

PDA

View Full Version : Javascript Question


claudelacey
04-19-2004, 01:53 PM
Hi guys

The following piece of javascript works perfectly in IE but not in Mozilla, any ideas why? I don't have much experience writing js so the problem could be staring at me right in the face and i wouldn't know it :( According to what I have read it should work in Mozilla

The problem is the top and left style settings don't seem to have any effect in Mozilla and the div remains in the top eft hand corner.

function writeMenus()
{
//Passenger Services
var passmenudiv = document.createElement('div');
var passdiv = document.getElementById('passenger_services');
document.body.appendChild(passmenudiv);
passmenudiv.ID = 'menu_passenger_services';

//set the style
passmenudiv.style.position = 'absolute';
passmenudiv.style.left = '500';
passmenudiv.style.top = '300';
passmenudiv.style.background = '#cfd9dd';
passmenudiv.style.border = 'thin solid #89a1aa';

//set the html
var str = '<table width="' + passdiv.width + '">';
str += '<tr><td height="20">Hello World</td></tr>';
str += '</table>';
passmenudiv.innerHTML = str;
}

claudelacey
04-20-2004, 05:13 PM
Nevermind, problem solved! The correct code for Mozilla to understand is:

passmenudiv.style.left = '500px';
passmenudiv.style.top = '300px';