About Pi Downloads Documentation Plugins Developer Forum Issues

pi.env2009-01-06 09:23:30

Summary

pi.env is a hash provides detecting the browser.Static properties inside of pi.env contains boolean values.

Syntax

pi.env.browserName

Usage Example

>>> if( pi.env.ie ){
	alert("You are using IE");
}

Properties

  • firefox
  • ie
  • ie6
  • ie7
  • ie8
  • opera
  • webkit

Examples

Example #1: Print a message by browser type.

Source files of the above example:

browserMessage.html

<div id="m_container"></div>

browserMessage.js

var message = ["Cool browser ;)","Hi, Safari User","Hi!"];
pi.get("m_container").innerHTML = message[ pi.env.firefox? 0: ( pi.env.webkit?1:2 ) ];