Results 1 to 6 of 6

Hybrid View

  1. #1
    Join Date
    Dec 2008
    Location
    Florida
    Posts
    49
    Plugin Contributions
    0

    Default specify javascript file for specific ez-page

    I am using 1.3.8a. I have a number of ez-pages in use. I have one ez-page that is using a javascript file placed in "includes/modules/page/" and that is working just fine.

    But the javascript code uses a document.getElementById and on the other ez-pages that do not require this javascript file, this code produces a javascript error (indicated by the yellow error triangle at the bottom left of Internet Explorer browser window).

    It's more of an annoyance than anything since the error isn't interfering with any of the ez-page operations other than that little yellow error triangle that bugs me to no end.

    What I did the try to fix this was I created another folder for the ez-page that uses the javascript file at "includes/modules/page_10/" and I moved the javascript file there.

    My thought was that the section in the html_header.php file where it loads all page-specific jscript_*.js files from includes/modules/pages/PAGENAME would take over and realize that the javascript file was now located in a folder that corresponded to the ez-page id "page_10"... but it doesn't. Instead it breaks that page and the javascript does not function.

    Am I not understanding the override system correctly? How would I load a javascript file for just one ez-page to avoid that nasty little triangle?

    TIA!

  2. #2
    Join Date
    Jan 2004
    Posts
    66,443
    Plugin Contributions
    279

    Default Re: specify javascript file for specific ez-page

    Can you add some conditional javascript to check for the existence of that ID , and only run the code related to it *if* that ID/element is found on the page?

    There isn't support for per-ez-page-javascript control at this point.
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  3. #3
    Join Date
    Dec 2008
    Location
    Florida
    Posts
    49
    Plugin Contributions
    0

    Default Re: specify javascript file for specific ez-page

    i am not a coder by any means and the javascript is a freebie with no support.

    you can see the script in action here - it is just a tab switcher script (remove spaces in url): http://www. orchidlakecandles .com/index.php?main_page=page&id=3

    the element it is looking for is the tab ID.

    i'll just have to get over it. lol

    the error is not obvious in Chrome or Firefox and most customers probably don't even notice IE's warning triangle.

  4. #4
    Join Date
    Jan 2004
    Posts
    66,443
    Plugin Contributions
    279

    Default Re: specify javascript file for specific ez-page

    Edit your jscript_tabs.js file, and replace this part:
    Code:
    menunr = menunr-1;for (i=1; i <= tabcount[menunr]; i++){document.getElementById(tablink_idname[menunr]+i).className='tab'+i;document.getElementById(tabcontent_idname[menunr]+i).style.display = 'none';}document.getElementById(tablink_idname[menunr]+active).className='tab'+active+' tabactive';document.getElementById(tabcontent_idname[menunr]+active).style.display = 'block';}var timer; counter=0;
    with this (highlighted sections are the added code differences), which will skip the javascript sections that are throwing errors because of missing components:
    Code:
    menunr = menunr - 1;for (i = 1; i <= tabcount[menunr]; i++) { if (document.getElementById(tablink_idname[menunr] + i)) document.getElementById(tablink_idname[menunr] + i).className = 'tab' + i; if (document.getElementById(tabcontent_idname[menunr] + i)) document.getElementById(tabcontent_idname[menunr] + i).style.display = 'none';} if (document.getElementById(tablink_idname[menunr] + active)) document.getElementById(tablink_idname[menunr] + active).className = 'tab' + active + ' tabactive';if (document.getElementById(tabcontent_idname[menunr] + active)) document.getElementById(tabcontent_idname[menunr] + active).style.display = 'block';}var timer; counter = 0;
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

  5. #5
    Join Date
    Dec 2008
    Location
    Florida
    Posts
    49
    Plugin Contributions
    0

    Default Re: specify javascript file for specific ez-page

    thank you very much for putting that out there for me to try.

    i used your code

    menunr = menunr-1;for (i=1; i <= tabcount[menunr]; i++){if (document.getElementById(tablink_idname[menunr]+i)) document.getElementById(tablink_idname[menunr]+i).className='tab'+i;if (document.getElementById(tabcontent_idname[menunr]+i)) document.getElementById(tabcontent_idname[menunr]+i).style.display='none';} if (document.getElementById(tablink_idname[menunr]+active)) document.getElementById(tablink_idname[menunr]+active).className='tab'+active+'tabactive';if (document.getElementById(tabcontent_idname[menunr]+active)) document.getElementById(tabcontent_idname[menunr]+active).style.display='block';}var timer; counter=0;}
    and I still get this:

    Webpage error details

    User Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; GTB6; .NET CLR 1.1.4322; .NET CLR 2.0.50727; InfoPath.2; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)
    Timestamp: Wed, 27 Jan 2010 22:12:07 UTC


    Message: 'document.getElementById(...)' is null or not an object
    Line: 27
    Char: 279
    Code: 0
    URI: http://www. orchidlakecandles .com/i...script_tabs.js

  6. #6
    Join Date
    Jan 2004
    Posts
    66,443
    Plugin Contributions
    279

    Default Re: specify javascript file for specific ez-page

    You could try this variation:
    menunr = menunr-1;for (i=1; i <= tabcount[menunr]; i++){if (document.getElementById(tablink_idname[menunr]+i) != null) document.getElementById(tablink_idname[menunr]+i).className='tab'+i;if (document.getElementById(tabcontent_idname[menunr]+i) != null) document.getElementById(tabcontent_idname[menunr]+i).style.display='none';} if (document.getElementById(tablink_idname[menunr]+active) != null) document.getElementById(tablink_idname[menunr]+active).className='tab'+active+'tabactive';if (document.getElementById(tabcontent_idname[menunr]+active) != null) document.getElementById(tabcontent_idname[menunr]+active).style.display='block';}var timer; counter=0;}
    .

    Zen Cart - putting the dream of business ownership within reach of anyone!
    Donate to: DrByte directly or to the Zen Cart team as a whole

    Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
    Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

 

 

Similar Threads

  1. Specify specific regions in a country for shipping
    By gmartakis in forum General Questions
    Replies: 5
    Last Post: 18 Jun 2013, 04:46 PM
  2. page specific javascript
    By sandyshore in forum Templates, Stylesheets, Page Layout
    Replies: 3
    Last Post: 24 Dec 2012, 12:28 AM
  3. CSS file for a javascript tabbed box overiding defaul settings on product page
    By ScootaMan in forum Templates, Stylesheets, Page Layout
    Replies: 0
    Last Post: 14 Nov 2007, 08:46 PM
  4. Specify to save download file
    By vwebworld in forum Setting Up Categories, Products, Attributes
    Replies: 3
    Last Post: 7 Aug 2007, 06:51 PM
  5. Calling Javascript file from main page
    By praiseandplay in forum Templates, Stylesheets, Page Layout
    Replies: 10
    Last Post: 5 Aug 2006, 04:41 AM

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