Ok i know i could spend ages looking through google for this answer and loads of people would say lots of thing but i just have a few questions to ask. What do you put in .js files ? Can i place my picture of the day in a .js file and then put a link to it up on the internet so people can have a picture of the day on thier site ? Thanx for your time
You put code in .js files. .js means javascript code just like .asp means ASP code and .php means PHP code -- except that ASP and PHP are server-side languages (meaning the webserver that serves the files executes the code then passes it to the client), whereas Javascript is a clientside language (meaning the web browser that the client is using that was passed the page processes the code while displaying it). You can include all your javascript code in your normal HTML file. Just surround it by script tags (use angle brackets instead of square brackets): [script language="Javascript]runMyJavascriptFunction();runAnotherFunction();return false;[/script] Or, you can take that code and put it in a .js file, then have the HTML load and run it using an HTML tag on the html page. If you want to rotate images or something, you have to keep your images separate, and write code inside the js file (or just inside your main HTML page, doesn't matter they're the same) that loads those other separate image files into your page.
Ok, I have this php script which randomly selects a picture each day to show from a folder in my root folder. Can i use something like include page.php in j.s? Or page.html ?
No. PHP is server-side code. All PHP code is already processed by the time it gets to the javascript. And the javascript is executed on the client, meaning the browser of the user that is accessing your website -- his browser is the one that runs the javascript code, whether it's IE or firefox or opera or whatever, that's what executes the javascript code. And that browser doesn't have access to any PHP code because PHP code is on your server, it is not passed to the browser. If you want to include your PHP script for rotating images or whatnot, just do an include in your main page (will have to be a .php page). You don't need javascript at all for that. Javascript is used for stuff happening after the page is already loaded, generally. Stuff like letting the user move things around on the page, or doing fancy things with the cursor, that kind of stuff.
But he can also do a javascript that will select a random URL for him ... and with facilities like AJAX , he can even get data from .txt filles or even mySQL database!
yes i can get it on my pages thats not the problem im trying to get it on other people websites? How do i do that ?