Random Quote AlertThis script will show an alert with a random quote from a set of 10 when the viewer clicks a button.Script CodeGrab a copy of the file below and place it in the same directory as the Web page on which you will use the script (if you wish to place the script file in a different directory you will need to make the necessary adjustments to the src attribute of the script tag that calls it).The code below should be placed between the <body> and </body> tags where you want the button to appear. ExampleA working sample of the script is shown below.OptionsYou can change the text of the quotes by opening the salert3.js file and editing the bold (strong) text on the following lines of code:
quote[0]="You clicked that button, didn\'t you?"; Additional quotes can be added by adding lines for quote[10], quote[11], and so on:
quote[10]="Quote Text"; If you need to use single or double quotation marks within a quote, you should write them with a backslash before them (i.e. \" and \') in order to avoid JavaScript errors. AccessibilityThis could be made accessible for those without JavaScript by directing the form action attribute to a server side script that will perform the same function (perhaps writing the quote on another page and allowing the viewer to go back). Another way might be to provide an HTML page with the list of quotes for those that can't get the alerts. |