Désolé, Bovino, mais il y a quelque chose qui ne tourne pas rond. Voilà le code HTML:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" >
<head>
<title>TEST PAGE</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="shortcut icon" type="image/x-icon" href="" />
<link rel="stylesheet" media="screen" type="text/css" title="test" href="test.css" />
<script type="text/javascript" src="test.js"></script>
</head>
<body>
<div id="canvas"></div>
</body> |
Et voilà le contenu de test.js:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| var mf;
function Frame(idstring) {
this.id = idstring;
this.left = document.getElementById(idstring).style.left;
this.top = document.getElementById(idstring).style.top;
this.width = document.getElementById(idstring).style.width;
this.height = document.getElementById(idstring).style.height;
this.state = 0;
}
window.onload = function() {
mf = new Frame("canvas");
alert(mf.left);
} |
Et, à tout hasard, le contenu de test.css:
#canvas {position: absolute; left: 120px; top: 121px; width: 122px; height: 123px; background: green;}
La bonne nouvelle, c'est que la compilation ne plante plus. La mauvaise, c'est qu'apparemment, les variables de mf après l'appel de la fonction constructeur sont null. Je ne vois pas ce qui cloche...
Partager