PDA

View Full Version : Overwriting JS functions


Dean C
12-22-2005, 12:31 PM
vBpagenav.prototype.form_gotopage = function(e)
{
if ((pagenum = parseInt(fetch_object('pagenav_itxt').value, 10)) > 0)
{
window.location = this.addr + '&page=' + pagenum;
}
return false;
};


That JS function is taken from vbulletin_global.js. All I have access to is the final page $output with all the HTML. I can't get inside that file and rewrite it dynamically, and I'm not going to ask my users to edit the JS file as I'm trying to keep away from any file edits. I've tried using inline JS to fix the problem by using:


$output = str_replace(
'<title>',
'
<script type="text/javascript">
vBpagenav.prototype.form_gotopage = function(e)
{
if ((pagenum = parseInt(fetch_object(\'pagenav_itxt\').value, 10)) > 0)
{
window.location = this.addr + \'?page=\' + pagenum;
}
return false;
};
</script>
<title>',
$output
);


I'm stumped.

Hmm it does seem to work. Nvm

filburt1
12-22-2005, 03:37 PM
Maybe try setting it to null to erase the anonymous function then reassigning it.