home *** CD-ROM | disk | FTP | other *** search
/ internet.au CDrom 42 / NETCD42.iso / web / w95 / dream2.exe / data1.cab / Program_Files / Configuration / Behaviors / Actions / Popup Message.js < prev    next >
Encoding:
JavaScript  |  1998-11-30  |  1.7 KB  |  76 lines

  1. // Copyright 1998 Macromedia, Inc. All rights reserved.
  2.  
  3. //*************** GLOBALS VARS *****************
  4.  
  5. //******************* BEHAVIOR FUNCTION **********************
  6.  
  7. //Passed a string, function calls alert() to popup a message.
  8.  
  9. function MM_popupMsg(theMsg) { //v2.0
  10.   alert(theMsg);
  11. }
  12.  
  13.  
  14. //******************* API **********************
  15.  
  16.  
  17. //Can be used with any tag and any event
  18.  
  19. function canAcceptBehavior(){
  20.   return true;
  21. }
  22.  
  23.  
  24.  
  25. //Returns a Javascript function to be inserted in HTML head with script tags.
  26.  
  27. function behaviorFunction(){
  28.   return "MM_popupMsg";
  29. }
  30.  
  31.  
  32.  
  33. //Returns fn call to insert in HTML tag <TAG... onEvent='thisFn(arg)'>
  34. //Calls escQuotes to find embedded quotes and precede them with \
  35.  
  36. function applyBehavior() {
  37.   var msgStr = escQuotes(document.theForm.message.value);
  38.   if (msgStr == '') {
  39.     return MSG_NoMsg;
  40.   } else {
  41.     return "MM_popupMsg('" + msgStr + "')";
  42.   }
  43. }
  44.  
  45.  
  46.  
  47. //Passed the function call above, takes prior arguments and reloads the UI.
  48. //Removes any escape characters "\"
  49.  
  50. function inspectBehavior(msgStr){
  51.   var startStr = msgStr.indexOf("'") + 1;
  52.   var endStr = msgStr.lastIndexOf("'");
  53.   if (startStr > 0 && endStr > startStr) {
  54.     document.theForm.message.value = unescQuotes(msgStr.substring(startStr,endStr));
  55.   }
  56. }
  57.  
  58.  
  59.  
  60. //***************** LOCAL FUNCTIONS  ******************
  61.  
  62.  
  63. //Set the insertion point
  64.  
  65. function initializeUI(){
  66.   document.theForm.message.focus(); //set focus on textbox
  67.   document.theForm.message.select(); //set insertion point into textbox
  68. }
  69.  
  70.  
  71.  
  72. //**************** GENERIC FUNCTIONS ****************
  73.  
  74. //function escQuotes(theStr){
  75. //function unescQuotes(theStr){
  76.