Total members 10262 | Gratitudes |It is currently Thu May 24, 2012 9:51 am Login / Join Codemiles


All times are UTC [ DST ]




Post new topic Reply to topic  Quick reply  [ 1 post ] 
Author Question
 Question subject: invalid argument on IE with script to center objects
PostPosted: Tue Sep 21, 2010 9:12 am 
Offline
Newbie
User avatar

Joined: Tue Sep 21, 2010 9:03 am
Posts: 1
Has thanked: 0 time
Have thanks: 0 time

Hi there! First time posting here! I hope you can help me.
I have a problem with a script I made to center horizontally and vertically an object with an id of "centered". This code works onLoad and every time the screen is resized. This works perfectly fine on firefox, chrome, and safari. For some reason I cannot understand why it doesn't work on IE. I get an error about an invalid argument on line 18, which is where I calculate the final position. here is the code:
any help would be greatly appreciated!

Code:
<html>
<head>
   
<script>
   
window.onresize = center;


function center(){

    var objwidth = document.getElementById('centered').offsetWidth;
    var objheight = document.getElementById('centered').offsetHeight;
    var screen_height = window.innerHeight;
    var screen_width = window.innerWidth;
    var centx = (screen_width/2) - (objwidth/2);
    var centy = (screen_height/2) - (objheight/2);
    document.getElementById('centered').style.position = "absolute";
    document.getElementById('centered').style.top = centy;
    document.getElementById('centered').style.left = centx;
   
}

</script>


</head>
<body onLoad="center();">
   
<table  border="1" id="centered" height="250" width="375">
    <tr><td>1</td><td>2</td></tr>
    <tr><td>3</td><td>4</td></tr>
</table>


   
   
   
</body>
</html>


TOP
 Profile Send private message  
Reply with quote  
Post new topic Reply to topic Quick reply  [ 1 post ] 
Quick reply


  

 Similar topics
 script for including files
 Invalid integer formats
 Dynamic Frame-sets with java script protocols
 need help with java script in a pdf
 How to import your website dump database script
 Get all objects for an entity
 How to create a file in java script using FireFox
 Boonex Dolphin PHP script is SCAM!!!
 How can I call a C program in a Shell Script from Java
 Questions: Perl Script. PHP.

All times are UTC [ DST ]


Users browsing similar posts

Users browsing this forum: No registered users and 1 guest



Jump to:  
Previous Question | Next Question 




Home
General Talks
Finished Projects
Code Library
Games
Tutorials

Java
C/C++
C-sharp
php
Script
JSP/Servlets
Ajax
ASP/ASP.net
Google SEO
Database
Communications
Phpbb3 styles
Photoshop tutorials
Flash tutorials
Find a job






Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
All copyrights reserved to codemiles.com 2007-2011
mileX v1.0 designed by codemiles team