Ree
Ree

Reputation: 259

Magento Javascript Error - Diagnosing

my javascript megamenu dropdown is not working and the sidebanner too. I think its a javascript problem but I am trying hard to determine what actually goes wrong.

I used google chrome "Inspect Element" > Console and there are 3 issues:

  1. TypeError: $.browser is undefined fixed: !$.browser.msie || $.browser.version > 6,
  2. Use of getPreventDefault() is deprecated. Use defaultPrevented instead.
  3. TypeError: $j.browser is undefined var safari = $j.browser.safari; /* We need to check for safari to fix the input:...

I would appreciate if anybody can point me to the correct directions on what is wrong with the javascript? Thank you in advance.

Upvotes: 0

Views: 87

Answers (1)

Lord Bafford
Lord Bafford

Reputation: 36

You should use less Div(s) in your code.

Your Two Drop-Menus : Account and Shop by Categories aren't working.

As for the sidebar, I believe your have wrong box dimensions. Your Bullon chart is cut.

Some of your Menus are longer than the rest.

What makes you believe that there is an error in your page ?

You should use the inner variables provided by browser. I have seen many translate code.

Here is a sample code :

function alertSize() {
  var myWidth = 0, myHeight = 0;
  if( typeof( window.innerWidth ) == 'number' ) {
    //Non-IE
    myWidth = window.innerWidth;
    myHeight = window.innerHeight;
  } else if( document.documentElement && ( document.documentElement.clientWidth || document.documentElement.clientHeight ) ) {
    //IE 6+ in 'standards compliant mode'
    myWidth = document.documentElement.clientWidth;
    myHeight = document.documentElement.clientHeight;
  } else if( document.body && ( document.body.clientWidth || document.body.clientHeight ) ) {
    //IE 4 compatible
    myWidth = document.body.clientWidth;
    myHeight = document.body.clientHeight;
  }
  window.alert( 'Width = ' + myWidth );
  window.alert( 'Height = ' + myHeight );
}

It was taken from HowtoCreate.co.uk

If you want to use drop menus, you need to use events like Click. W3C has many code samples and good documentation.

Here is a fun code sample from W3C School :

<!DOCTYPE html>
<html>

<body>
<h1 onclick="this.innerHTML='Ooops!'">Click on this text!</h1>
</body>

</html>

You can always use JQuery if you want the easy or effective method. Javascript has many libraries that you can use.


See this page to find deprecated and obsolete functions in JQuery : http://api.jquery.com/category/deprecated/

You can find deprecated functions in Javascript in this page : "Mozilla Deprecated and Obsolete features"

If you want to continue using old functions, you can downgrade or make use of plug-ins to restore old features.

Upvotes: 1

Related Questions