Hello, I found this online to change images daily. I have several images I would like to do this with so I want to make this an external javascript file instead of putting it in the source code because it will be real big. The page I got this from had this code put directly into the body. Since I don't want this in the body but want it externally, I tried putting a regular .js call command in my web page to call it as I do with normal javascript functions but it doesn't work. Seems to me I need a way to insert the image it selects into my page. Anyone know what kind of command in the body section will insert the daily image into my page? Lastly I have a seperate script I am looking at that has this in its code: document.body.background=imgs[nday] It puts background images all over the page and I only want one. Anyone know how to change the just mentioned string so it only shows one image instead in the whole body? Thanks a lot. Jen <script> <!-- var mondayimg="http://www.yourwebsite.com/yourgraphic.gif" var tuesdayimg="http://www.yourwebsite.com/yourgraphic.gif" var wednesdayimg="http://www.yourwebsite.com/yourgraphic.gif" var thursdayimg="http://www.yourwebsite.com/yourgraphic.gif" var fridayimg="http://www.yourwebsite.com/yourgraphic.gif" var saturdayimg="http://www.yourwebsite.com/yourgraphic.gif" var sundayimg="http://www.yourwebsite.com/yourgraphic.gif" var mydate=new Date() var today=mydate.getDay() if (today==1) document.write('<img src="'+mondayimg+'">') else if (today==2) document.write('<img src="'+tuesdayimg+'">') else if (today==3) document.write('<img src="'+wednesdayimg+'">') else if (today==4) document.write('<img src="'+thursdayimg+'">') else if (today==5) document.write('<img src="'+fridayimg+'">') else if (today==6) document.write('<img src="'+saturdayimg+'">') else document.write('<img src="'+sundayimg+'">') //--> </script>
insert between: <head></head> Code (markup): that code: <script language="javascript" type="text/javascript" src="your_js_file.js"></script> Code (markup):
Thanks but it looks like I need something more than that to call the javascript function, but don't waste your time, I found one I like better.
you can not call that, because it's not a function. if you wite that code in <script> function function_name() { your code here } </script> it's ok. and than call it with like <body onLoad="function_name();" ...>