Hi, This is likely something very simple but I am a newbie so be gentle please. I have written a proof of concept "hello world" script which works in IE7 when tested - great. I then sent the .htm file to a device called a NETIOM - we have a use for this which I won't bore you with. It has a very basic web server and has a tiny amount of storage for scripts and web pages (no server side script support). When I point IE7 (or Firefox) at the NETIOM it gets the file, actions the html and ignores the Javascript completely! Is this a Javascript thing or am I being a fool? This is the sample code below. Thanks Mosschops <html> <body> <td><FORM METHOD=GET action="test.htm"> <form> <table> <tr> <th>Test</th> <td><input type=submit name=A09 value="Switch 1 On"></td> <td><input type=submit name=A10 value="Switch 2 On"></td> </tr> <tr> <td><input type=submit name=B09 value="Switch 1 Off"></td> <td><input type=submit name=B10 value="Switch 2 Off"></td> </tr> </table> <table> <tr> <td><b>State of Switch 1<b></td> <td>%61</td> </tr> <tr> <td><b>State of Switch 2<b></td> <td>%62</td> </tr> </table> </form> <SCRIPT LANGUAGE="Javascript"> <!-- document.write("<i>Hello World!<i>"); //--> </SCRIPT> </body> </html>
I'm not a fan of using document.write. That may or may not be the problem. But you may want to try building your .html document like the following. Also, it helps to use the code tags when posting code. It's the # on the toolbar. And, tables shouldn't be used inside a form. Tables shouldn't be used for page layout. Use CSS for layout, and tables for displaying tabular data. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>Any Title</title> <script type="text/javascript"> function init(){ document.getElementById('something').innerHTML = "Hello World"; } onload=init; </script> </head> <body> <div id="something"></div> <form method="get" action="test.htm"> </form> </body> </html> Code (markup):
Many thanks Mike - the script now runs from the unit. Now I have proved the concept I will have to learn the language properly and work out where to go from here. Can you recommend any books (UK)/web sites for self teaching Javascript, I am not a programmer but have dabbled a little with C at college and some html. Cheers Greg
You're welcome, Greg. Visit www.w3schools dot com for many free tutorials. And validate your code here: validator.w3 dot org jigsaw.w3.org/css-validator/