India seo web development website designer freelance

A simple menu command

The following menu command is associated with two menu items: Undo and Redo. It checks the arguments attribute of the menuitem tag and performs a dw.undo() or a dw.redo() operation, depending on the value of the first (and only) argument.

<HTML> <HEAD> <!-- Copyright 1999 , Inc. All rights reserved. --> <TITLE>Edit Clipboard</TITLE> <SCRIPT LANGUAGE="javascript"> function receiveArguments() { if (arguments.length != 1) return; var whatToDo = arguments[0]; if (whatToDo == "undo") { dw.undo(); } else if (whatToDo == "redo") { dw.redo(); } } function canAcceptCommand() { var selarray; if (arguments.length != 1) return false; var bResult = false; var whatToDo = arguments[0]; if (whatToDo == "undo") { bResult = dw.canUndo(); } else if (whatToDo == "redo") { bResult = dw.canRedo(); } return bResult; } function setMenuText() { if (arguments.length != 1) return ""; var whatToDo = arguments[0]; if (whatToDo == "undo") return dw.getUndoText(); else if (whatToDo == "redo") return dw.getRedoText(); else return ""; } </SCRIPT> </HEAD> <BODY> </BODY> </HTML>

In this command, the receiveArguments() function processes the arguments and executes the command. More complex menu commands might call different functions to execute the command. For example, the following code checks whether the first argument is "foo" ; if it is, it calls the doOperationX() function and passes it the second argument. If the first argument is "bar" , it calls the doOperationY() function and passes it the second argument. doOperationX() or doOperationY() is responsible for executing the command.

function receiveArguments(){ if (arguments.length != 2) return; var whatToDo = arguments[0]; if (whatToDo == "foo"){ doOperationX(arguments[1]); }else if (whatToDo == "bar"){ doOperationX(arguments[1]); } }

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