OK then, mmm - After playing with this quite a bit I see now that the wopenpop() function is simply broken. If it ever was OK, due to browser changes, it no longer is. And bindTheEvent(), though apparently serviceable, is ill advised. It could be rewritten to not depend upon strings so much. But I'm not going to worry about that at the moment. I did do that, but there's no guarantee it will dovetail with the rest of the code, which presumably is written using the same arcane approach.
We can dance around that some and make bindTheEvent work together with wopenpop in most but not all cases. Or we can bite the bullet and demand that wopenpop be changed. It can be changed in such a way that will not affect anyone who has come to depend upon it for this and/or other uses. Or we can use bindTheEvent to change it, again in such a way that will not affect anyone who has come to depend upon it for this and/or other uses.
Here's how wopenpop should be:
Code:
function wopenpop(url, name, w, h)
{
w += 32;
h += 96;
var win = window.open(url, name, 'width=' + w + ', height=' + h + ', ' + 'location=no, menubar=no, ' + 'status=no, toolbar=no, scrollbars=no, resizable=no');
try{win.resizeTo(w, h);}catch(e){}
win.focus();
}
Now, if still we cannot change it even though this will not hurt anyone else who is using it for this or any purpose, we can as I say write our change to it into bindTheEvent (addition highlighted):
Code:
// ---------------------------------------------------
// Binds the listener event to a page element
// ---------------------------------------------------
function bindTheEvent(elem7, relation) {
window.wopenpop = function(url, name, w, h)
{
w += 32;
h += 96;
var win = window.open(url, name, 'width=' + w + ', height=' + h + ', ' + 'location=no, menubar=no, ' + 'status=no, toolbar=no, scrollbars=no, resizable=no');
try{win.resizeTo(w, h);}catch(e){}
win.focus();
};
// Check if the element is a form, if so it sets the onsubmit event. Otherwise sets onclick event
var eventString = (elem7.nodeName.toLowerCase() == 'form' ? 'onsubmit' : 'onclick');
// Gives a unique ID to the element if it doesnt have one already
elem7.id ? null : elem7.id = 'jsct' + relation;
// Start creating (and formatting) the function string to set the element's event to
var evalString = 'TrackFormula("' + elem7.id + '", ' + userKey + ', ' + domainKey + ', ' + relation;
// Grab the previous onsubmit or onclick function of the element to pass into the listener function
var previousFunction = (elem7.nodeName.toLowerCase() == 'form' ? String(elem7.onsubmit) : String(elem7.onclick));
// *** Configure the element to run the previous function after running the new tracking function
evalString += (previousFunction == 'undefined' || previousFunction == 'null' ? '' : ', "' + previousFunction.substring(previousFunction.indexOf('{') + 1, previousFunction.length - 1).replace(/"/g, '\\"').replace(/(\r\n|\n|\r)/gm, '') + '"') + ');return false;';
// Set new function to the newly configured string function
eval('elem7.' + eventString + ' = function(){' + evalString + '}');
}
Now regardless how we do that, whether it's in the above function or by changing wopenpop itself, once we do one or the other of those two, all we need to do is (as we already had) remove the return false from the link:
Code:
<a id="formulas" onclick="return wopenpop('formulas.html', 'popup', 760, 575);" href="formulas.html">Show Formulas (opens in Popup window)</a>
Bookmarks