View Full Version : script to globally disable onclick

10-13-2008, 12:44 AM
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.


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.

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.


Thanks in advance.

10-13-2008, 09:23 AM
can you post the code that defines the onclick event?

10-13-2008, 05:09 PM
Here are three lines that currently appear. Note, each time we add or modify a calendar entry the link ID reference changes.

<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.


Let me know your thoughts, and thanks.

10-13-2008, 06:37 PM
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"



<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(){
'script type="text/javascript">',
'</head> ',
'<body style="font-family:times, "Times New Roman", serif;" > ',
'<center> ',
'</center></body></html> ',

function pugCloseWin(){
// Recommended - include onunload="pugCloseWin();" in the <body> tag.
if (pugWindow && !pugWindow.closed){ pugWindow.close(); }

var Secure=true;

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>
&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>

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




10-13-2008, 09:52 PM
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.