Start Building Professional
Web Apps Today


 
Categories Question details Back To List
Question  posted by Babu on Jan 16, 2009 07:24
open dhtmlx forum
onload function throws up an error

The seemingly simple code below fails to invoke the function DisplayGrid() in IE 7 , but works well in Safari.
On loading the page I get "Object expected" javascript error at the line " <BODY onload="DisplayGrid()">"

Any idea ?


<HTML>
<HEAD>
<TITLE>Table display evaluation</TITLE>
<link rel="stylesheet" type="text/css" href="codebase/dhtmlxgrid.css"/>    
<script src="codebase/dhtmlxcommon.js" />
<script src="codebase/dhtmlxgrid.js" />
<script src="codebase/dhtmlxgridcell.js" />
<script type="text/jscript">
    function DisplayGrid()    
    {
        alert("DisplayGrid");
    }
</script>
</HEAD>
<BODY onload="DisplayGrid()">
<div>
    <table id="tableGrid">
        <tr><td>Column1</td><td>Column2</td><td>Column3</td></tr>
        <tr><td>a1</td><td>a2</td><td>a3</td></tr>
        <tr><td>b1</td><td>b2</td><td>b3</td></tr>
    </table>
</div>
</BODY>
</HTML>
Answer posted by Support on Jan 16, 2009 09:34
a) script tag must always have closing tag
b) correct type - text/javascript

<script src="codebase/dhtmlxcommon.js" ></script>
<script src="codebase/dhtmlxgrid.js" ></script>
<script src="codebase/dhtmlxgridcell.js" ></script>

<script type="text/javascript"> 
  function DisplayGrid()  
  { 
  alert("DisplayGrid"); 
  } 
</script>