...

View Full Version : mov a div



g00fy
09-07-2006, 08:16 AM
i have some asp.net doing some funky things, and it puts me in the position of having to move a div (centrescreen) as i am call it to be displayed
... but ...
i want to put the code on the div and nothing else, to centre it.

this is my embedded javascript resource code


var _width = 0;
var _height = 0;

var _mbWidth = 0;
var _mbHeight = 0;

if (parseInt(navigator.appVersion) > 3)
{
if (navigator.appName == "Netscape")
{
_width = window.innerWidth - 16;
_height = window.innerHeight - 16;
}
if (navigator.appName.indexOf("Microsoft") != -1)
{
_width = document.body.offsetWidth - 20;
_height = document.body.offsetHeight - 20;
}
}

function CentreScreen(id)
{
var win = document.getElementById(id);

if(null == win) { return; }
if(_width == 0 || _height == 0) { return; }

_mbWidth = win.offsetWidth;
_mbHeight = win.offsetHeight;

if(null == _mbWidth || null == _mbHeight) { return; }

var _left = ((_width - _mbWidth) / 2);
var _top = ((_height - _mbHeight) / 2);

win.style.top = _top + 'px';
win.style.left = _left + 'px';
}

then i would like to add an event (or something) on the div in my asp.net code that creates my div element, similar to this



if (Display == Display.CenterScreen)
{
writer.AddAttribute("onfocus", "CentreScreen('" + this.ID + "');");
}


can anyone help me please?

kind regards,
g00fy

g00fy
09-07-2006, 08:53 AM
its ok i got it :D



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum