Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

positioning 1

Status
Not open for further replies.

aperfectcircle

Programmer
Apr 3, 2001
290
US
This can't be very hard, but I can't seem to get it right...
I have some javascript that checks the user's browser, and if it is Netscape 6 or higher I want to change the position of a div.
I know the browser-check thingy and my if statement works, because I can use it to change the background color for Netscape 6, but I just can't seem to get the positioning stuff...

Can anyone tell me the correct way to use javascript to position an element?

Thanks
 
Just make sure you are calling the code after the element has been created, otherwise it will not exist yet, and will not be moved - so you need either use the code in a function called onLoad - or in script tags embedded in the page after the element is created.

function set(){
if((navigator.appName.indexOf("Netscape") !=-1) && (document.getElementById)){
document.getElementById('elem_1').style.top = 500;
}
}


You can use either an integer - or a string for the new positions.
b2 - benbiddington@surf4nix.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top