How to Build Web Site Script
Scripts add functionality to your website and can be used for such things as processing forms; activating buttons, menus or pop-up windows; providing date/time stamps on the page; browser and operating system detection; and merging content from separate files into one Web page. They allow for some interaction between the visitor and your content, and can also provide animation to make it more dynamic. Two common types of scripts for websites are PHP and Javascript.
Instructions
-
PHP Scripting: Adding a Date/Time Stamp
-
1
Open your Web editing tool and start a new Web page. When you save the page, be sure to give it the extension .php instead of .htm or .html. PHP scripts will only run on .php pages.
-
2
Add content to your Web page, then click where you would like to add a "Last Updated" notice. The date/time stamp will be provided by a PHP command.
-
- 3
-
4
Save your file changes, upload the PHP file to your server and view it in your browser to test the results. PHP scripts do not run on the local machine, and PHP must be installed on the Web host's server in order to run PHP pages.
Javascript: Creating a Pop-up Window
-
5
Open your Web editing software and create a new Web page.
-
6
Add some content and then add a thumbnail-size image of a JPG graphic you'd like to appear in the new window at its original (larger) size when the thumbnail is clicked.
-
7
Click to select the thumbnail, and create a link to the larger graphic.
-
8
Edit the HTML code for that link to include Javascript to pop up a new window as part of the A tag. Paste this code after A HREF=":
javascript:void(0)" onclick="window.open(' -
9
Paste this code after the link URL but before the IMG tag:
', 'New_Window','width=500,height=450')"> -
10
Check that all together your Javascript looks similar to:
<a href="javascript:void(0)"
onclick="window.open('http://www.mydomain.com/large_image.jpg',
'New_Window','width=500,height=450')">
<img src="http://www.mydomain.com/thumbnail.jpg" alt="Picture Title" width="262" height="180" border="0" /></a> -
11
Save your file changes. Upload the Web page with the Javascript, and the two image files, to your Web server. View the Web page in your browser to test the pop-up window action.
-
1
Tips & Warnings
PHP and Javascript are available for free from online script libraries. See Resources for some locations to get you started. If you use a Web editing tool with scripting abilities like Adobe Dreamweaver, you can automatically create Javascript code for rollover buttons and other interactive features without any programming experience at all.
Downloaded scripts come with a "read me" file or instructions at the top of the code file. Read the instructions carefully before adding the script to your website, and always give credit to the programmer.