Quellcode in NetBeans und Visual Studio auf- und zuklappen

Normalerweise erlaubt die IDE das auf- und zuklappen von Quellcode nur bei Klassen- oder Methodendefinitionen. In Microsoft Visual Studio kann aber Quellcode, der von den Direktiven #region und #endregion umgeben ist, im Ganzen zusammengeklappt werden. Im genauen Beispiel sieht das dann so aus:

#region Hello World!
void myFunctionOne()
{
  ...
}

void myFunctionTwo()
{
  ...
}
#endregion

Die NetBeans IDE verfügt mit editor-fold über eine ähnliche Verhaltensweise wie Visual Studio mit #region.

// <editor-fold defaultstate="collapsed" desc="Hello World!">
  protected void myFunctionOne(
    ...
  }
 
  protected void myFunctionTwo(
    ...
  }
// </editor-fold>

Screenshot:

netbeans-editor-fold

Check for HTML5 features with JavaScript

There is no magic behind checking a web-browsers support for a specific HTML5 feature. If you want to check if a browser supports the latest HTML5 WebSocket API then you just have to take care if there is an object called „WebSocket“ available via the DOM:

<script>
  if('WebSocket' in window){
    alert('Hurray! Your browser supports HTML5 WebSockets.')
  }else{
    alert('Sorry, but you are out of date!');
  }
</script>

Nevertheless, there are still people who want to include a fancy library for such an inspection. You can do the same with Modernizr:

<script src="http://www.modernizr.com/downloads/modernizr-latest.js"></script>
<script>
  if(Modernizr.websockets){
    alert('Hurray! Your browser supports HTML5 WebSockets.')
  }else{
    alert('Sorry, but you are out of date!');
  }
</script>