views:

35

answers:

1

Hello,

I can't get my dojo working. I've tried everything.

Here is the code:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
<html>
<head>

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/dojo/1.4/dojo/dojo.xd.js"&gt;


    dojo.addOnLoad(function(){
    console.log("page ready, can modify DOM anytime after this");

});
</script>

</head>
<body>

</body>
</html>
+3  A: 

Take your code and put it in another script tag after the dojo script tag:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/dojo/1.4/dojo/dojo.xd.js"&gt;&lt;/script&gt;
<script type="text/javascript">
dojo.addOnLoad(function(){
    console.log("page ready, can modify DOM anytime after this");
});
</script>

A script tag with an src attribute cannot also contain code, unless you use a John Resig-like hack.

Sean Vieira
Thanks, but where does the output from console.log go?
pfdevil
In your example, it doesn't ever actually get called ... the browser just ignores it completely.
Sean Vieira
Yes, I know. But with firebug, I use console.debug to get output to the console. Where does console.log go?
pfdevil
@pfdevil -- the same place :-)
Sean Vieira