1

I have WordPress website which I updated to version 5.5

Now I get error:

Uncaught TypeError: Cannot read property 'msie' of undefined
    at jquery.tools18.min.js?ver=10.2.2:281
    at jquery.tools18.min.js?ver=10.2.2:358
(index):738 Uncaught TypeError: $(...).live is not a function
    at HTMLDocument.<anonymous> ((index):738)
    at i (jquery.js?ver=1.12.4-wp:2)
    at Object.fireWith [as resolveWith] (jquery.js?ver=1.12.4-wp:2)
    at Function.ready (jquery.js?ver=1.12.4-wp:2)
    at HTMLDocument.J (jquery.js?ver=1.12.4-wp:2)

I tried to apply this fix:

https://bootstrapcreative.com/uncaught-typeerror-cannot-read-property-msie-of-undefined/

by adding this into header.php of the template that I use:

<!doctype html>
<html <?php language_attributes(); ?>>
<head>
    <meta charset="<?php bloginfo( 'charset' ); ?>">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <link rel="profile" href="https://gmpg.org/xfn/11" />
    <?php wp_head(); ?>
    
    <script>
       
        jQuery.browser = {};
        (function () {
            jQuery.browser.msie = false;
            jQuery.browser.version = 0;
            if (navigator.userAgent.match(/MSIE ([0-9]+)\./)) {
                jQuery.browser.msie = true;
                jQuery.browser.version = RegExp.$1;
            }
        })();
    </script>
        
</head>

But it's not working. I get the same error. Do you know how I can fix this issue?

Peter Penzov
  • 1,126
  • 134
  • 430
  • 808

1 Answers1

0

My best guess is that jQuery is added to the footer of your site, not in the header.

Ideally, you would create a javascript file in your theme that you can include and specify it is dependent on jQuery; that way, you can be certain your code will always be loaded after jQuery, whether it's loaded in the header or the footer.

  1. So place everything you have between your tags in a separate file in your theme: let's call it "scripts.js"

  2. In your theme's functions.php file, you want to load that script as a dependent of jQuery:

    add_action('wp_enqueue_scripts', 'my_theme_name_enqueue_scripts'); function my_theme_name_enqueue_scripts() { wp_enqueue_script('my-theme-name-js', get_template_directory_uri() . '/scripts.js', array('jquery')); }

That 3rd argument to the wp_enqueue_script function call is an array of other scripts yours depends on.

For a full list of script handles/names WordPress makes available to you, see here

nibnut
  • 3,072
  • 2
  • 15
  • 17