Page 1 of 2 12 LastLast
Results 1 to 10 of 13
  1. #1
    Join Date
    Jun 2012
    Posts
    361
    Plugin Contributions
    0

    Default Javascript Uncaught TypeError

    Chrome browser displays shopping cart help information using entire screen despite javascript window.open height and width parameters in includes/modules/pages/shopping_cart/jscript_main.php code. This behavior is not encountered in Firefox and Safari browsers. The problem appears in unmodified out-of-the-box zc157c and 157d. Chrome's JavaScript Console reports an Uncaught TypeError: cannot read properties of null (reading 'focus'). Relevant code follows:
    Code:
    <script src="includes/general.js" type="text/javascript"></script>
    <script type="text/javascript">
    function popupWindow(url) {
      window.open(url,'popupWindow','toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=no,width=550,height=550,screenX=150,screenY=100,top=100,left=150,noreferrer')
    }
    function session_win() {
      window.open("<?php echo zen_href_link(FILENAME_INFO_SHOPPING_CART); ?>","info_shopping_cart","height=460,width=430,toolbar=no,statusbar=no,scrollbars=yes,noreferrer").focus();
    }
    </script>
    The line in red highlights where the problem lies. Removing "noreferrer" from the line eliminates the javascript error and Chrome, Firefox, and Safari all display the help text in a sized pop-up window. Also, according to W3 Schools here there is no "noreferrer" parameter, and no "statusbar" parameter, only "status".

    I am only a novice with javascript. The code is from 2006. There are other cases throughout zencart where noreferrer is used in window.open. Maybe the javascript code should be reviewed and updated.

    Dave
    zc157c, php 8.0.2, mysql 8.0.28

  2. #2
    Join Date
    Apr 2006
    Location
    West Salem, IL
    Posts
    2,703
    Plugin Contributions
    0

    Default Re: Javascript Uncaught TypeError

    I just installed a fresh 157c and I don't get the same behavior, as far as width is concerned. The "popup" does open the full height of the window but the width is restrained. noreferrer was added by Dr. Byte in 1.5.7a, strange that it was not brought over to the 1.5.8 code in progress. Also noreferrer is allowed, see: https://developer.mozilla.org/en-US/...PI/Window/open
    Mike
    GeekHost - Zen Cart Certified & PCI Compliant Hosting
    The Zen Cart Forum...Better than a monitor covered with post-it notes!

  3. #3
    Join Date
    Jun 2012
    Posts
    361
    Plugin Contributions
    0

    Default Re: Javascript Uncaught TypeError

    Confirmed that noreferrer was added in 1.5.7a so the code was looked at recently. Installed a fresh version of Chrome (v103); the original version was v102. same problem, same javascript error. The popup window comes up sized the same size as the shopping cart page. I had Chrome sized the entire screen width and height in my original tests. Gotta be a Chrome problem, not a zen cart bug.

  4. #4
    Join Date
    Jan 2004
    Location
    N of San Antonio TX
    Posts
    8,622
    Plugin Contributions
    9

    Default Re: Javascript Uncaught TypeError

    The noreferrer was added for accessibility requirements BUT, this one is not required as the link is internal. If it were "referring" to the docs link, it would need to be there.

    It might have been set in a batch fix of 1.5.7. It is required in the external links (e.g. ZC links in the footer).

    I am getting the same view in 1.5.7 that mike is getting with Chrome 103.0.5060.53

    Also, 1.5.8 draws an accuratge 460 x 430 when help is clicked.

    Have you made sure there's not some css in your template that's making the change?

  5. #5
    Join Date
    Jun 2012
    Posts
    361
    Plugin Contributions
    0

    Default Re: Javascript Uncaught TypeError

    But a CSS problem would affect Firefox and Safari too. Correct?

  6. #6
    Join Date
    Apr 2006
    Location
    West Salem, IL
    Posts
    2,703
    Plugin Contributions
    0

    Default Re: Javascript Uncaught TypeError

    I think the issue with "Uncaught TypeError: cannot read properties of null (reading 'focus')" is the .focus() at the end of that line. I don't believe that is required to be there.
    Mike
    GeekHost - Zen Cart Certified & PCI Compliant Hosting
    The Zen Cart Forum...Better than a monitor covered with post-it notes!

  7. #7
    Join Date
    Apr 2006
    Location
    West Salem, IL
    Posts
    2,703
    Plugin Contributions
    0

    Default Re: Javascript Uncaught TypeError

    Quote Originally Posted by dbltoe View Post
    Also, 1.5.8 draws an accuratge 460 x 430 when help is clicked.
    I noted above that the noreferrer is NOT present in the 1.5.8 version of that file I find it strange that a change to 1.5.7a was not carried forward into 1.5.8
    Mike
    GeekHost - Zen Cart Certified & PCI Compliant Hosting
    The Zen Cart Forum...Better than a monitor covered with post-it notes!

  8. #8
    Join Date
    Apr 2006
    Location
    West Salem, IL
    Posts
    2,703
    Plugin Contributions
    0

    Default Re: Javascript Uncaught TypeError

    I do prefer the way the Bootstrap template handles these "popups" by having converted them to modals.
    Mike
    GeekHost - Zen Cart Certified & PCI Compliant Hosting
    The Zen Cart Forum...Better than a monitor covered with post-it notes!

  9. #9
    Join Date
    Jan 2004
    Location
    N of San Antonio TX
    Posts
    8,622
    Plugin Contributions
    9

    Default Re: Javascript Uncaught TypeError

    Sorry, didn't see the mention of the browser tests.

    Normally, Chrome and Safari seem to be in lock step while Firefox does its thing. It's unusual that you are getting the same "incorrect" results from all of them.

    As to the focus... Without it there, clicking a second time with the pop-up open and underneath the browser might result in the pop-up not being seen. However, it might be better coded as
    Code:
    newwindow=window.open("<?php echo zen_href_link(FILENAME_INFO_SHOPPING_CART); ?>","info_shopping_cart","height=460,width=430,toolbar=no,statusbar=no,scrollbars=yes,noreferrer");
    if (window.focus) {newwindow.focus()}
    I'll leave that to the experts.

  10. #10
    Join Date
    Apr 2006
    Location
    West Salem, IL
    Posts
    2,703
    Plugin Contributions
    0

    Default Re: Javascript Uncaught TypeError

    with focus the way it is now you can hide the popup by clicking on the page outside the popup so it doesn't do what you would want anyway. Basically, if you click the help link a second time and the popup exists it should just focus on the existing popup and not generate a new one, but the way it is currently coded I can keep clicking help and opening more popups. So it needs to be reworked in some way.
    Mike
    GeekHost - Zen Cart Certified & PCI Compliant Hosting
    The Zen Cart Forum...Better than a monitor covered with post-it notes!

 

 
Page 1 of 2 12 LastLast

Similar Threads

  1. Replies: 4
    Last Post: 8 Mar 2018, 07:48 AM
  2. v139h Uncaught TypeError: $ (...). EasySlider is not a function
    By boqn_2007 in forum Addon Templates
    Replies: 2
    Last Post: 17 Apr 2017, 12:39 AM
  3. Replies: 4
    Last Post: 25 May 2016, 09:33 PM
  4. Uncaught ReferenceError: cssjsmenu is not defined
    By unclemantis in forum Installing on a Linux/Unix Server
    Replies: 3
    Last Post: 13 Sep 2013, 05:01 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
disjunctive-egg
Zen-Cart, Internet Selling Services, Klamath Falls, OR