Guest User

btipling

a guest
Nov 23rd, 2008
140
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
  2. "http://www.w3.org/TR/html4/strict.dtd">
  3. <html>
  4. <head>
  5. <title>shared var</title>
  6. <script type="text/javascript">
  7. var foo = "awesome";
  8. bar = "bartastic";
  9. window.baz = "bazzoom";
  10. function checkBaz1(){
  11. alert("baz:" + window.baz);
  12. }
  13. </script>
  14. <script type="text/javascript">
  15. if(!window.foo) var foo = "not awesome";
  16. if(!window.bar) var bar = "not bartastic";
  17. function checkBaz2(){
  18. alert("baz:" + window.baz);
  19. }
  20. </script>
  21. </head>
  22. <body>
  23. <p>Foo is <script type="text/javascript">document.write(foo);</script></p>
  24. <p>Bar is <script type="text/javascript">document.write(bar);</script></p>
  25. <p>Baz is <script type="text/javascript">document.write(baz);</script></p>
  26. <p><a href=#" onclick="checkBaz1(); return false;">checkBaz1</a></p>
  27. <p><a href=#" onclick="checkBaz2(); return false;">checkBaz2</a></p>
  28. </body>
  29. </html>
  30.  
  31.  
RAW Paste Data