I have a task to dispaly a div starts from the left position of some other control.
I had searched on so many sites but, unfortunately I have not found any good solution.
But, finally I found a solution, as I know the default left on 1024 x 768 is "251" so I use this as a gift of god.
Following is the code how to do that:-
var obj=document.getElementById("a1");
var int_left=screen.width; // get Pixel size of screen
if (int_left>1024)
{
int_left=int_left-1024; // get width other then 1024
int_left=int_left/2; get the first half of width
int_left=int_left+251; add first half to the width
}
else
{
int_left=253;
}
obj.style.left=int_left;
If you have any doubts please let me know.
Set Left,Top at different screen resolution by JavaScript
![](http://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjdFOQN1NfH5bq8tt8j1unZFJ2EcPEQShAK4-Sp7v27n8TZEbXVXpRwcjyOm5sNJkzm0VBClpM6dbXDN7l0ZI6c3q1CoTvDlaYuwU8ztVPhyxw2vfCOuVTwDRW2Pj5HBg/s220/logo.jpg)
No comments:
Post a Comment