tinker Posted January 26, 2008 Share Posted January 26, 2008 Hi, Let's suppose i've got this simple example: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <meta http-equiv="Content-Type" content="text/html;charset=utf-8" > <title>Layer test</title> <style type='text/css'> #test_layer { position: absolute; top: 100px; left: 200px; visibility: visible; background-color: #efefef; } </style> <script type="text/javascript"> function layer_get(id) { return document.getElementById(id).style; } function layer_moveto(x, y, id) { var l = layer_get(id); l.left = x; l.top = y; } </script> </head><body> <div id="test_layer"> This is our test layer </div> <h2>Layers</h2> <a href="#" onclick="layer_moveto(50, 50, 'test_layer')">Move</a><br> <br><br> </body></html> However because it lacks a full doctype definition it will fall back to quirksmode. However if I use: <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> it passes muster with the validator but the script throws error's saying that 'top' and 'left' have been dropped because of a parse error. So, my questions are, does it really matter that I use the first doctype shown here, how bad is it to fall back to quirksmode (since it's transitional anyway (and I think it falls back to some form of quirksmode anyway)), and is there a way to use a full doctype and the script to work? W3C VALIDATOR Quote Link to comment Share on other sites More sharing options...
Daniel0 Posted January 26, 2008 Share Posted January 26, 2008 About quirks mode: http://en.wikipedia.org/wiki/Quirks_mode What do you mean with "the script throws errors"? What script? Quote Link to comment Share on other sites More sharing options...
tinker Posted January 27, 2008 Author Share Posted January 27, 2008 The javascript, in the error console... (I've already read that, i'm looking for an answer!) Quote Link to comment Share on other sites More sharing options...
bronzemonkey Posted January 27, 2008 Share Posted January 27, 2008 Your javascript is probably where the error lies if you're getting problems when using a proper doctype. Perhaps the JS forum is where to look for some help modifying your code? Quote Link to comment Share on other sites More sharing options...
wildteen88 Posted January 27, 2008 Share Posted January 27, 2008 These two lines in your javascript l.left = x; l.top = y; need to be: l.left = x + 'px'; l.top = y + 'px'; You must provide the unit. Quote Link to comment Share on other sites More sharing options...
tinker Posted January 28, 2008 Author Share Posted January 28, 2008 I like's it, oh so simple but obvious when you know how, cheers. (I put this here because I thought it was a DOCTYPE issue? cross issues!) yipieeeee! Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.