Adobe contribute Javascript Script Error

553 Views Asked by At

My client uses Adobe Contribute to edit their web pages. One of the pages uses AllWebMenus, which is JS based. I also use jQuery scripts on the same page.

When editing the page in Contribute the following error is displayed:

An Error has occurred in the script on this page.

Error: Unable to get property 'getComputedStyle' of undefined or null reference.

URL http://www.fountainvalley.org/menus/awmdata/awmlib2.js.

Code: 0

Not sure if it related, but the jQuery on the page has to be 1.8 for one of my scripts to function properly.

http://fountainvalley.org/government/departments/publicworks/watermeters.php

Anyone have any ideas on how to fix this?

1

There are 1 best solutions below

1
On

I obviously don't know much about the nature of your project, but given the fact that that method is failing (which it will when the element it's being called on doesn't exist), I would assume that whatever is trying to build the menu is running before the HTML part of the menu exists on the page.

It looks like you have a call to create the menu, and it is before the HTML for the menu. I would move this line:

<script type="text/javascript">awmBuildMenu();</script>

after your anchor for the menu, which is:

<div id="topnav"> <span id='awmAnchor-fv-top'>&nbsp;</span> </div>

Or, as a good practice, another option would be to move that (and all of your JavaScript references and code) to right before </body>.

One last option would be to leave that method call where it is, but wrap it in a jQuery DOM-ready handler:

<script type="text/javascript">
    $(function() {
        awmBuildMenu();
    });
</script>

For the record, I don't see any errors browsing the site with Chrome.