Assuming you have static pages with <html><head></head><body>whatever</body></html>
kind of stuff. The following should work and be a quick fix. My method modifies the bottom closing </body>
tag but you can modify it to alter the <head>
or opening <body>
tag
.htaccess
<IfModule php5_module>
php_value auto_prepend_file /var/www/vhosts/example.com/httpdocs/auto_prepend.php
php_value auto_append_file /var/www/vhosts/example.com/httpdocs/auto_append.php
</IfModule>
auto_prepend.php
<?php
ob_start();
?>
auto_append.php
<?php
$output = ob_get_clean();
$script = file_get_contents($_SERVER['DOCUMENT_ROOT'].'/script.inc');
$output = str_replace('</body>', $script.PHP_EOL.'</body>', $output);
echo $output;
?>
script.inc
<script>
// using jquery method to attach onload:
jQuery(function(){
// do your js stuff here or load your external js, like with jQuery.getScript() or jQuery.ajax()
// http://api.jquery.com/jQuery.getScript/
// http://api.jquery.com/category/ajax/
});
// or if you want go without a framework and attach your onload event.
// in the most cross browser way see:
// http://stackoverflow.com/questions/1235985/attach-a-body-onload-event-with-js
</script>