India seo web development website designer freelance

The Behaviors API

Two Behaviors API functions are required ( applyBehavior() and behaviorFunction() ); the rest are optional.

applyBehavior()

Description

Inserts into the user's document an event handler that calls the function that behaviorFunction() inserts. This function can also perform other edits on the user's document, but it must not delete the object to which the behavior is being applied or the object that receives the action.

Arguments

uniqueName

The argument is a unique identifier among all instances of all behaviors in the user's document. Its format is functionNameInteger , where functionName is the name of the function that behaviorFunction() inserts. This argument is useful if you insert a tag into the user's document and you want to assign a unique value to its NAME attribute.

Returns

expects a string that contains the function call to be inserted in the user's document, usually after accepting parameters from the user. If applyBehavior() determines that the user made an invalid entry, the function can return an error string instead of the function call. If the string is empty ( return ""; ), does not report an error; if the string is not empty and not a function call, displays a dialog box with the text: Invalid input supplied for this behavior: [the string returned from applyBehavior()] . If the return value is null ( return; ), indicates that an error occurred but gives no specific information.

Note: Quotation marks within the returned string must be preceded by a backslash (\) to avoid errors that the JavaScript interpreter reports.

Example

The following instance of applyBehavior() returns a call to the function MM_openBrWindow() and passes parameters that are given by the user (the height and width of the window; whether the window should have scroll bars, a toolbar, a location bar, and other features; and the URL that should open in the window):

function applyBehavior() { var i,theURL,theName,arrayIndex = 0; var argArray = new Array(); //use array to produce correct ¬ number of commas w/o spaces var checkBoxNames = new Array("toolbar","location",¬ "status","menubar","scrollbars","resizable"); for (i=0; i<checkBoxNames.length; i++) { theCheckBox = eval("document.theForm." + checkBoxNames[i]); if (theCheckBox.checked) argArray[arrayIndex++] = ¬ (checkBoxNames[i] + "=yes"); } if (document.theForm.width.value) argArray[arrayIndex++] = ("width=" + ¬ document.theForm.width.value); if (document.theForm.height.value) argArray[arrayIndex++] = ("height=" + ¬ document.theForm.height.value); theURL = escape(document.theForm.URL.value); theName = document.theForm.winName.value; return "MM_openBrWindow('"+theURL+"',¬ '"+theName+"','"+argArray.join()+"')"; }

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117

India web developer website development India