Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jun 17th, 2012  |  syntax: None  |  size: 1.23 KB  |  hits: 24  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. <!DOCTYPE html>
  2. <html>
  3.  <head>
  4.          <meta http-equiv="content-type" content="text/html;charset=UTF-8" />
  5.          <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  6.          <title>Untitled</title>
  7.          <meta name="viewport" content="width=device-width, minimum-scale=1, maximum-scale=1" />
  8.          <meta name="apple-mobile-web-app-capable" content="yes" />
  9.          <link type="text/plain" rel="author" href="/humans.txt" />
  10.          <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
  11.          <script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.13/jquery-ui.min.js"></script>
  12.          <!--[if lt IE 9]>
  13.          <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
  14.          <![endif]-->
  15.          <style type="text/css">
  16.          
  17.          </style>
  18.  </head>
  19.  <body>
  20.  
  21.  <script>
  22.  
  23.  var message = 'I am global';
  24.  
  25.  function iCanHazGlobalScope (a) {
  26.         $('<h1>', {
  27.                 text: a
  28.         })
  29.         .css({color: 'blue'})
  30.         .appendTo($('body'));
  31.  }
  32.  
  33.  (function ($) {
  34.  
  35.          var message = 'I am scoped';
  36.  
  37.          function iCanHazGlobalScope (a) {
  38.                 $('<h2>', {
  39.                         text: a
  40.                 })
  41.                 .css({color: 'red'})
  42.                 .appendTo($('body'));
  43.          }
  44.          
  45.          iCanHazGlobalScope(message); // output: I am scoped
  46.  
  47.  } (jQuery));
  48.  
  49.  iCanHazGlobalScope(message); // output: I am global
  50.  
  51.  
  52.  </script>
  53.  </body>
  54. </html>