Uncaught ReferenceError: gadgets is not defined

1.5k views Asked by At

I am working on google gadgets. When I load my html file in browser, I am getting javascript error "Uncaught ReferenceError: gadgets is not defined".

HTML code is given below,

<html>
<head>
    <script>
      var prefs = new gadgets.Prefs();
      gadgets.window.adjustHeight();
    </script>
</head>
<body>
<h1>Hey there!!..</h1>
</body>
</html>

The screen shot showing the above html in action in chrome browser is attached.

Please help me to resolve this error. Thanks

html code in action

1

There are 1 answers

0
jasonscript On

The gadgets JS reference has not been loaded.

Based on the code that you've provided, you're either not loading it at all, or the resource has not finished loading by the time you're calling new gadgets.Prefs()

You should load your js dependencies, and then use a document.onReady event to execute your script once the dependencies have loaded