Created
August 24, 2010 08:54
-
-
Save wolfhesse/547227 to your computer and use it in GitHub Desktop.
rel:lang:javascript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script> | |
<script type="text/javascript"> | |
$(document).ready( function(){ | |
(function(){ | |
var url = document.URL; | |
var userAgent = navigator.userAgent.toLowerCase(); | |
var browser = { | |
version: (userAgent.match( /.+(?:rv|it|ra|ie)[\/: ]([\d.]+)/ ) || [])[1], | |
safari: /webkit/.test(userAgent), | |
opera: /opera/.test(userAgent), | |
msie: (/msie/.test(userAgent)) && (!/opera/.test( userAgent )), | |
mozilla: (/mozilla/.test(userAgent)) && (!/(compatible|webkit)/.test(userAgent)) | |
}; | |
// create a div with id 'something' | |
$('<div id=something>').text('something').appendTo(document.body); | |
$('#browser-version').text(browser.version); | |
$('#isSafari').text((browser.safari)?'is Safari/weblit':'is not Safari/webkit'); | |
$('#isMozilla').text((browser.mozilla)?'is Mozilla':'is not Mozilla'); | |
$('#isMsie').text((browser.msie)?'is Msie':'is not Msie'); | |
$('#isOpera').text((browser.opera)?'is Opera':'is not Opera'); | |
// replace text of #something | |
$('#something').text('changed'); | |
// create 5 numbered divs | |
ids=[3,22,11,15,17]; | |
// for(i in ids){$('<span />').text(ids[i]+', ').appendTo(document.body);} | |
accum=$('<p />'); cSpan=$('<span />'); | |
spangen=function(anId){ return $('<span id="'+anId+'"/>'); } | |
tmp = ids.map(function(i,c){ accum.append( spangen("id-span-"+c).text(i+', ') ); }); | |
accum.appendTo(document.body); | |
// see log | |
console.profile( function(){ | |
if(console.log) { console.log('here'); } | |
console.log('tryin'); | |
}); | |
console.profileEnd(); | |
}()); | |
}); | |
</script> | |
<div id="browser-version">534.3</div> | |
<div id="isSafari">is Safari/weblit</div> | |
<div id="isMozilla">is not Mozilla</div><div id="isOpera">is not Opera</div> | |
<div id="isMsie">is not Msie</div> | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment