By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,117 Members | 1,093 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,117 IT Pros & Developers. It's quick & easy.

How do I use this code multiple times on a page

P: 1
Hi there. Working on my site currently and I would like to know how I can use this code more than once on the page

Expand|Select|Wrap|Line Numbers
  1. <script language="JavaScript">
  2. <!-- 
  3. // This is the function that will open the
  4. // new window when the mouse is moved over the link
  5. function open_new_window() 
  6. {
  7. new_window = open("","hoverwindow","width=300,height=200,left=10,top=10");
  8.  
  9. // open new document 
  10. new_window.document.open();
  11.  
  12. // Text of the new document
  13. // Replace your " with ' or \" or your document.write statements will fail
  14. new_window.document.write("<html><title>JavaScript New Window</title>");
  15. new_window.document.write("<body bgcolor=\"#FFFFFF\">");
  16. new_window.document.write("This is a new html document created by JavaScript ");
  17. new_window.document.write("statements contained in the previous document.");
  18. new_window.document.write("<br>");
  19. new_window.document.write("</body></html>");
  20.  
  21. // close the document
  22. new_window.document.close(); 
  23. }
  24.  
  25. // This is the function that will close the
  26. // new window when the mouse is moved off the link
  27. function close_window() 
  28. {
  29. new_window.close();
  30. }
  31.  
  32. // -->
  33. </script>
  34.  
  35.  
  36. <a href="#" onMouseOver="open_new_window()" onMouseOut="close_window()">Open Hover Window</a>
Apr 23 '14 #1
Share this question for a faster answer!
Share on Google+

Post your reply

Sign in to post your reply or Sign up for a free account.