This is tested and works:
Code:
<!DOCTYPE html>
<html>
<head>
<title>Load a Day of the Week Script</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="shortcut icon" href="http://home.comcast.net/~jscheuer1/favicon.ico" />
</head>
<body>
<script type="text/javascript">
(function(){
var s = document.createElement('script');
s.type = 'text/javascript';
s.src = ['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'][new Date().getDay()] + '.js?bustcache=' + new Date().getTime();
document.getElementsByTagName('head')[0].appendChild(s);
})();
</script>
</body>
</html>
Demo: http://home.comcast.net/~jscheuer1/s...kdayscript.htm
The browser cache may need to be cleared and/or the page refreshed to see changes.
There may be some limitations upon what such a script (monday.js, tuesday.js, etc.) can do, for example, if they include the document write or writeLn methods, they might overwrite the existing page. But most things will work as expected. And in the above code, these day scripts must be in the same folder as the page that's using them (although they could, with a minor change to the code go in another folder).
If you want to use jQuery, use:
http://api.jquery.com/jQuery.getScript/
Code:
<!DOCTYPE html>
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.8/jquery.min.js"></script>
<script type="text/javascript">
$.getScript(['sunday', 'monday', 'tuesday', 'wednesday', 'thursday', 'friday', 'saturday'][new Date().getDay()] + '.js');
</script>
</body>
</html>
Demo: http://home.comcast.net/~jscheuer1/s...ayscriptjq.htm
If you want more help, please include a link to the page on your site that contains the problematic code so we can check it out.
Bookmarks