home *** CD-ROM | disk | FTP | other *** search
/ Chip 2005 June / ccd0605.iso / Offline / Migrate / Port Windows IPC apps to Linux, Part 1 Processes and threads_files / emailfriend2.js < prev    next >
Encoding:
JavaScript  |  2005-04-25  |  2.1 KB  |  46 lines

  1. // developerWorks e-mail to a friend JavaScript
  2. // Adapted from Danny Goodman's
  3. // "JavaScript Bible, 3rd Edition" (www.dannyg.com)
  4. // Initialize global var for new window object
  5. // so it can be accessed by all functions on the page
  6. var emailWindow 
  7. // set flag to help out with special handling for window closing
  8. var isIE3 = (navigator.appVersion.indexOf("MSIE 3") != -1) ? true : false
  9. // make the new window and put some stuff in it
  10. function newWindow() {
  11.         //var output = ""
  12.         //emailWindow = window.open('','subwindow','HEIGHT=530,WIDTH=600,resizable=yes,scrollbars=yes')
  13.         // take care of Navigator 2
  14.         //if (emailWindow.opener == null) {
  15.         //        emailWindow.opener = window
  16.         //}
  17.  
  18.         //output += "<html><BODY BGCOLOR='#FFFFFF' TEXT='#000000'>"
  19.         //output += "<form name='emailIt' method='post' action='/developerworks/secure/email-it.jsp'>"
  20.         //output += "<input type=hidden name=subject value=\"" + justTitle + "\">"
  21.         //output += "<input type=hidden name=url value=\"" + document.location.href + '?e' + "\">"
  22.         //output += "<input type=hidden name=body value=\"" + emailAbstract + "\">"
  23.         //output += "</form>"
  24.         //output += "</body>"
  25.         //output += "</html>"
  26.  
  27.         //this.document.write(output)
  28.         //this.document.emailIt.submit();
  29.         //emailWindow.document.close()
  30.         
  31.  
  32.  
  33.         window.location.assign("https://www-136.ibm.com/developerworks/secure/email-it.jsp?subject=" + escape(justTitle) + "&url=" + escape(document.location.href) + "&body=" + escape(emailAbstract));
  34. }                  
  35. // close subwindow, including ugly workaround for IE3
  36. function closeWindow() {
  37.         if (isIE3) {
  38.                 // if window is already open, nothing appears to happen
  39.                 // but if not, the subwindow flashes momentarily (yech!)
  40.                 emailWindow = window.open("","subwindow","HEIGHT=200,WIDTH=200")    
  41.         }          
  42.         if (emailWindow && !emailWindow.closed) {
  43.                 emailWindow.close()
  44.         }          
  45. }                 
  46.