Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New to the CF scene
    Join Date
    Oct 2008
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    script to globally disable onclick

    I want to write a JavaScript that either ignores all onclick link references found in the text of the page file, or does a search and replace whereby the following string is found and replaced with nothing.

    Code:
    onclick="popupEvent

    BACKGROUND:
    I'm using a third-party calendar program. The program is designed to produce both a mouseover, "title" window, and an onclick, pop up window tied to dates where events are scheduled. The calendar view I'm using produces a mini, month-at-a-glance view.

    My web site has both a member (private) and public section. I want the onclick feature active in the member section, but don't want it to work in the public section . The public calendar is used to show non-members what great events they are missing by not being members, and is there to generate sales. All I want for the public calendar is the "title" window. Anything more would give away the farm, so to speak.

    SET UP:
    To insert one of the calendar's 4 views into any web page, you place the same two lines of code in the php file; one in the header, and one just below the <body> tag. Those set up the basic calls to display any calendar "views" you want to display. Then within the body of the page, you inset a line of code to call the calendar you wish, where you want it to show up. It is that simple.

    The source code that makes up the final, displayed calendar page is a combination of the original code, and that code inserted from multiple php files from which it was called. That "called" code includes the onclick link references. What I want to do is insert a master or global java script into the "parent" pages, that ignores any and all onclick commands that may have been inserted there, or replaces them with nothing - effectively disabling them.

    I am using two separate files (web pages) to display this calendar; one in the public section and one in the private section. The challenge is that the calendar software isn't set up to allow the popup to be turned off and on at the file (page) level, just globally for "all" pages. If it did I could have the global feature "on" and turn off the pop up on the public page just by adding a line of code. But, alas, no luck. Please note... the calendar's documentation / support forum does provide some on/off code strings, just not for this pop up.

    To make one of my calendars private, I've copied that file (with calendar code inserted as indicated above) into a secure folder on my server. The other page lives in a separate, non-secure (public) directory. Both pages call the same calendar, but are different web page files stored in different directories.

    I spent two days hacking and testing the calendar's php-based, program files to try to circumvent this process, but just no luck. Primary reason is that a few of the pages are scrambled so they can't be hacked, therefore I cannot modify them.

    That leaves me with trying to disable the onclick references in the my public file, and here I am.

    Suggestions?

    Thanks in advance.
    Barbara

  • #2
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,501
    Thanks
    3
    Thanked 500 Times in 487 Posts
    can you post the code that defines the onclick event?
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/

  • #3
    New to the CF scene
    Join Date
    Oct 2008
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Requested onclick code

    Here are three lines that currently appear. Note, each time we add or modify a calendar entry the link ID reference changes.

    Code:
      <td class="s24" title="Court Research " onclick="popupEvent(2454749,550,420)" style="cursor: pointer;">9</td>
      <td class="s23" title="Sub 2 Webinar " onclick="popupEvent(2454750,550,420)" style="cursor: pointer;">10</td>
      <td class="s23" title="Big Seminar Teleconference " onclick="popupEvent(2454722,550,420)" style="cursor: pointer;">12</td>
    And, I can even do better than the above. Below is the uri for a mock calendar I put online. If you right click and download this php file, and open it in a text editor (WordPad leave the structure in place), then click on the same link to open it in a web browsers, right click to view the source, and compare the two text versions of the file, you can see the before and after views of the code.

    http://www.karnescorner.com/calendar...iew-public.php

    Let me know your thoughts, and thanks.
    B

  • #4
    Senior Coder
    Join Date
    Mar 2005
    Location
    Portsmouth UK
    Posts
    4,501
    Thanks
    3
    Thanked 500 Times in 487 Posts
    Code:
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
        "http://www.w3.org/TR/html4/loose.dtd">
    
    <html>
    
    <head>
      <title></title>
    
    <script  type="text/javascript">
    <!--
    // Script produced with PopUpGenerator
    // by Vic Phillips http://www.vicsjavascripts.org.uk
    
    // Insert this script between the <header> tags
    
    var pugWindow=null;
    
    function pugWindow0Do(){
     pugCloseWin();
     pugWindow=window.open('','pugWindow0','width=190px,height=190px,resizable=yes');
     pugWindow.document.open();
     pugWindow.document.write(
     '<head><TITLE>fred</TITLE>',
     '<',
     'script  type="text/javascript">',
     'alert(opener.Secure);',
     '<',
     '/script>',
     '</head> ',
     '<body style="font-family:times, "Times New Roman", serif;"  > ',
     '<center> ',
     'tom<br>',
     '',
     '</center></body></html> ',
     '');
     pugWindow.document.close();
    }
    
    function pugCloseWin(){
    // Recommended - include onunload="pugCloseWin();" in the <body> tag.
     if (pugWindow && !pugWindow.closed){ pugWindow.close(); }
    }
    
    var Secure=true;
    //-->
    </script>
    
    Im assuming that the calendar is opened in a standard popup<br>
    If this is the case a variable from the opening page can be passed to the popup.<br>
    <br>
    so<br>
    <br>
    &lt;script type="text/JavaScript"> <br>
    &lt;!--                                <br>
    function popupEvent(ev, w, h) {            <br>
     if (opener.Secure){<br>
      var winl = (screen.width - w) / 2;       <br>
      var wint = (screen.height - h) / 2;
      win = window.open("/calendar/functions/popup.php?ev=" + ev + "&readFile=0&readSQL=1&showCat=&oc=1","Calendar","scrollbars=yes,status=no,location=no,toolbar=no,menubar=no,directories=no,resizable=yes,width=" + w + ",height=" + h + ",top=" + wint + ",left=" + winl + ""); <br>
      if (parseInt(navigator.appVersion) >= 4) { win.window.focus(); }    <br>
      }
     }<br>
    //-->
    &lt;/script><br>
    
    <br>
    <br>
    <a onclick="pugWindow0Do();" >Open PopUp</a>
     </head>
    
    <body>
    
    </body>
    
    </html>
    Vic

    God Loves You and will never love you less.

    http://www.vicsjavascripts.org/Home.htm

    If my post has been useful please donate to http://www.operationsmile.org.uk/

  • #5
    New to the CF scene
    Join Date
    Oct 2008
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Decipher your code

    Reading through your code, I see it has two sets of <header> and <body> tags, as well as a script (one closest to the top) that doesn't seem to close and another that begins unexpectedly. So... I need your help if deciphering what I"m looking at.

    And, so that I don't waste your time, it looks as if the code is contingent upon the onclick string containing "pubWindow0Do(); , as referenced below.

    <a onclick="pugWindow0Do();" >Open PopUp</a>

    However, if that is the case, then this won't work for me. You see, I have no way to edit that part of the script. It is scrambled in a separate file that gets called in order to generate the onclick lines of code. If, however, I'm missing something, I would appreciate your pointing out what I'm missing.

    Thanks in advance.
    Barbara


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •