  
|
|
Concrete examples help put you on the left track a lot faster. Below are tidbits of Javascript and PHP source code. Feel free to use and modify this material to add functionality to your own site. The scripts are subjects to an attribution license, but you are free to use them in commercial projects.
|

PHP, the hypertext preprocessor, is an absolutely outstanding scripting language. It can generate HTML-content after your instructions. This can be used to include headers and footers, generate graphics on the fly or connect to an SQL database.
i2 STUDIOS' website is based on this technology.
create_tableheader.inc Downloads: 31 Views: 72 |
Creates 1..n no of clickable headers that alternates ascending and descending queries of a SQL database driven table in a dynamic webpage.
Functions Included
createTableHeader(Page to direct the request to, Text to display at webpage, Text to use when searching database)
Call the function createTableHeader 1..n times depending on the number of headers you need.
Instructions
Clicking the same header more than one time switches between ascending and descending query.
Four different images can be used to make the header more intuitive: asc-on, asc-off, desc-on, desc-off. A set of them can be downloaded at http://www.i2studios.com/download/tablebuttons.zip
The text changes color to reflect which header is in use.
For an example of how to use it, see the source of the demo page (access it via a link from the page itself).
Try Demo |
|
resolution_statistics.zip Downloads: 36 Views: 671 |
The Sizemograph lets you collect, organize and graphically analyze the statistics about screen settings and browser information of people who come to your website.
Functions Included
Multiple scripts to collect information and store it.
horisontalDiagram(diagram_values, title, width, height, filename)
Instructions
The scripts is divided into two halves. Collect.php first collects the variables needed then reloads and inserts them in a MySQL database. The second page is resolution_statistics.php that via graphical diagrams generated instantly help you understand if your site is adequately designed as to size, browser brand and browsing habits of your clients.
Try Demo |
|
string-functions.inc Downloads: 26 |
Contains string manipulating functions using regular expressions.
Functions Included
getStem(filename)
getSuffix(filename)
Instructions
|
|
|

Below are some libraries containing some of the Javascripts that make this site tick.
They are created as external .js-files that can be included in an HTML-document by a single line of code:
<script type="text/javascript" src="PATH-TO-THE-SCRIPT"></script>
glide.js Downloads: 30 Views: 108 |
Glide in/out menu using div-tag and Math.sin() to smoothly open/close the menu when clicked.
Functions Included
glide(direction)
Instructions
Hide menues that you only need from time to time, reducing a potentially clutted look of a webpage.
First create a div tag that contains the elements you want to glide in and out (see the script source for details).
Then include the javascript library in any webpage. To make an object glide in/out create a clickable object such as a link or an image to act as the trigger.
Change the speed by adjusting the multiplier to the y=[multiplier]*Math.sin(angle). View the source from the demo page for more information.
Try Demo |
|
login_countdown.js Downloads: 16 Views: 53 |
Graphical progress bar thatautomatically updates itself and counts down from 100% to 0% and then invokes an action (like a logout-page).
Functions Included
updateTime();
Instructions
Used to give visual feedback to users that login to websites for a limited time. NOTE: this function does not include the code necessary to login/logout the user or create the cookies to keep a user logged in.
Start the recurring update once and it will continue to run until the progress bar reaches 0.
>body onload="updateTime()"<
Try Demo |
|
show_hide.js Downloads: 42 Views: 98 |
Show/hide button that displays and hides a portion of the page, reflowing the text as it goes on and off (just like the + below)
Functions Included
function toggleDisplay(indicator, object)
Instructions
Hide the content until the user asks for it. Then hide it again and watch the text reflow instantly.
Try Demo |
|
update_frames.js Downloads: 21 |
This very simple script checks if a document is loaded without a required frameset. For example, people accessing your site from a search engine might stumple into a page whose navigation is located in another frame. This script loads the entire frameset to include the navigation.
Functions Included
None. Just a single line of code.
Instructions
Include the script in all pages that should always be opened as a subframe in a frameset environment.
This function is used at this site to make sure no user is left without the possibility to navigate, since all navigation here is made in the topmost frame.
If a user directly accesses a subpage (for example via a search engine) the script reloads the page with the requested document as part of the frameset.
Try opening this frameset depending page and notice how it quickly adjusts.
|
|
update_title.js Downloads: 11 |
Updates the frameset title so it matches the title of the page viewed. Frames can leave the user with the never-changing title of the frameset instead of each and every subpage the user visits. This scripts checks the title of the document the script is included in, and updates the topmost frame's title.
Functions Included
None! Just a single line of code is necessary. (top.document.title=self.document.title)
Instructions
Include the script in each page in a frameset environment that should update the frameset title.
|
|
antispam.js Downloads: 30 Views: 49 |
Fool the e-mail sniffing scripts that extracts your e-mail address and then sends you spam. One way of finding your e-mailaddress is by scanning the html code of your website, looking for potential e-mailaddresses (mailto: strings).
This solution is very simple and therefore not foolproof. But it is likely to shake of most spambots.
Functions Included
function sendmail(scrambled user, scrambled domain)
Un-scrambles the user and domain and glues the two correct strings into a correct e-mail address. Then redirects the page to a "mailto:..." address that invokes the user's default e-mail client.
Instructions
Include this in link tag:
a href="javascript:void(0)" onclick="sendmail('nonsense_stringfirstname.lastname','mycompany¤com');"
Select what two strings to use when scrampling the correct information, then scramble all addresses on your website accordingly. The example above uses 'redherring' as the username scrambler and '¤' instead of dots in the domain name. This is the default setting. The image that replaces the @ character is only needed if you chose to write your e-mail address and not just use 'webmaster' or 'get in touch' as the linked text.
The script is now set up to first de-scramble the strings, then to concatenate the name and domain submitted to the function sendmail() to a complete href="mailto:name@domain.com" address on the fly, when the user clicks an e-mail address.
Try Demo |
|
preload.js Downloads: 32 |
Starts preloading of graphics in the background before the user actually requests the graphics.
Functions Included
function startPreload()
function preloadImages(image_array[1..x])
Instructions
Define what images to load in the array by entering the path to each image, then use onload="startPreload()" in the body tag (or similar) to launch the script. startPreload() in turn will call preloadImages()
|
|
|
|

This work is licensed under a
Creative Commons License.
View how this site works, and feel free to download the published scripts that make it happen.
 | Try the Sizemograph: the tool that keeps track of visitors' screen settings. |
Tired of spam? Fool the spambots without affecting the friendly users.
antispam.js
|
|