Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: mov a div

  1. #1
    New Coder
    Join Date
    Jan 2003
    Posts
    60
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post mov a div

    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

    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


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

    can anyone help me please?

    kind regards,
    g00fy

  • #2
    New Coder
    Join Date
    Jan 2003
    Posts
    60
    Thanks
    0
    Thanked 0 Times in 0 Posts
    its ok i got it


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •