Spectacular Free Slide Show MP3 Sound Streamer Email Link Encoder Stream Website Audio Cool Free Text Scroller

CodeLifter.com
Software & Scripts by CodeBrain.com
Home

JavaScripts
PopUp Maker
-
popup windows

CodeLifter 5
-
source viewer

ScrollBar Styler
-
color scrollbars

Flash Fixer
-
remove alerts

Roll-Over Maker
-
image roll-overs

Link Cloaker 5
-
encrypt links

Site Capture 3
-
hidden frames

CHMOD 2 Utility
-
chmod utility

BlackBird 3.0
-
browser shell

Zoom 1.0
-
magnifier
MicroTicker.com
-
text scroller

CodeBrain.com
-
java applets

D3Q.com
-
xp icon control

BrainCode.com
-
java applets

MailToProtector
-
protect email
Java Applets
Perl Scripts
Affiliate Program
PopUp Maker 5 :: Technical Note
Attaching PopUp Maker (or other) JavaScript Functions to a Button
Attaching PopUp Maker (or other) JavaScript Functions to a Button

Attaching a JavaScript function to a button is easy; generally done with the onClick event.

For PopUp Maker, say you made code for the function called doPopUp (the default name), and have already inserted the <script>...</script> as per instructions in the <head>...</head> of your page.

To use a function with any event, the correct general form is event="someFunction()" -- so the correct general form is onClick="doPopUp()" to attach the doPopUp function to the onClick event.

Since a button is technically a <form> element, note that, for sake of compatibility with older browsers, you must wrap the button in form tags.  (This is not strictly required in many newer browsers versions; but it's a good precaution to do it, anyway, for purposes of best compatibility.)

Putting it together, it looks like this simple example:

<form>
<input type="button" value="Click Me"
onClick="doPopUp()">
</form>


(Note that it is common to use onClick="javascript:doPopUp()" -- but not technically required.  Per se, the javascript: prefix is a protocol, and usually required only within the href= of an <a> anchor tag -- but not in an event call.)

Sample:

Although the example above is for our PopUp Maker application, the same general approach is used when attaching any JavaScript function to a button.

General cautions:  Observe punctuation carefully.  Don't forget to include the paired parentheses at the end of the function name.  In cases of functions other than those make by PopUp Maker, parentheticals may or may not carry variables; but PopUp Maker parentheticals are always empty.

.

Get The Code! CodeLifter is a CodeBrain.com Sister Site
© 1995-2008 OEC Corp & CodeLifter.com
CodeLifter™ & CodeBrain™
Legal Notices


CodeBrain InterNET Group
BrainCode.com CodeFoot.com CodeBelly.com
D3Q.com etLux.com FFFast.com
IEFix.com PopUpWorks.com MicroTicker.com
DavidSosnowski.com OECCorp.com MailToProtector.com
CodeBrain.com
Announcements



Free MP3
Downloads


Contemporary classical music, completely free.

.