Home Tutorials Forums Articles Blogs Movies Library Employment Press

Go Back   ActionScript.org Forums > Supporting Technologies > HTML and JavaScript

Reply
 
Thread Tools Rate Thread Display Modes
Old 05-06-2005, 03:30 PM   #1
andehlu
this modern love
 
andehlu's Avatar
 
Join Date: Aug 2004
Location: torontoCANADA
Posts: 429
Default javascript to position absolute div

Does anyone know how to position an absolte div using javascript? I have the following code so far but it doesnt seem to work... i tried taking the top and left attributes out of the inlkine style and that didnt work either.... thanks

PHP Code:
<html>
<
head>

<
title>2005 YOPLAIT Minigo Duo Campaign  Online Advertising</title>
    
<
script>
function 
handle_div(){
    
document.getElementById('div_layer').top 345;
    
document.getElementById('div_layer').left 345;
}
</script>

</head>
<body onLoad="handle_div()">

body content

<div id="div_layer" style="position: absolute; left: 400; top: 100; width: 200; height: 200; z-index: 1; visibility: visible;">
    <img src="media/animated.gif">
</div>
    
</body>
</html> 
andehlu is offline   Reply With Quote
Old 05-06-2005, 03:41 PM   #2
andehlu
this modern love
 
andehlu's Avatar
 
Join Date: Aug 2004
Location: torontoCANADA
Posts: 429
Default

this is why:

document.getElementById('div_layer').style.pixelLe ft = 200;
andehlu is offline   Reply With Quote
Old 05-06-2005, 03:41 PM   #3
sleekdigital
I like pizza!
 
Join Date: Feb 2003
Location: PA
Posts: 1,310
Send a message via AIM to sleekdigital Send a message via MSN to sleekdigital Send a message via Yahoo to sleekdigital
Default

You are close ...

document.getElementById('div_layer').style.top = 345;
document.getElementById('div_layer').style.left = 345;
sleekdigital is offline   Reply With Quote
Old 05-06-2005, 04:51 PM   #4
andehlu
this modern love
 
andehlu's Avatar
 
Join Date: Aug 2004
Location: torontoCANADA
Posts: 429
Default

yup thanks i also had to target for IE

this works on everything:

PHP Code:
    if (navigator.appName.indexOf("Microsoft")!=-1) {
        
toppos document.body.clientHeight 100;
        
leftpos document.body.clientWidth 100;
    }else{
        
toppos window.innerHeight 100;
        
leftpos window.innerWidth 100;
    } 
andehlu is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

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

Forum Jump


All times are GMT. The time now is 06:47 AM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.