The Cowboy

Recent Posts


Subscribe to
Posts [Atom]



Monday, February 12, 2007

Javascript cool feature of the day: on Browser Ready

I have a nice little one-liner script you can use in your HMTL page to run some a function when the browser is done loading the HTML.

I have been using this cool little snippet for a while, something I factored down for my own purposes, and tucked away in my little bag of tricks. I didn't realize that others' were not using something similar to this, (I saw a spate of posts where people were using document.write)[SHUDDER!]. So, I'm going to post it, and let the world rejoice:

var _my_init = document.addEventListener ? document.addEventListener("DOMContentLoaded", function(){myinit();}, false): setInterval( function(){if (/loaded|complete/.test( document.readyState )){ clearInterval(_my_init);myinit(); } }, 10);

Works in IE, FireFox, and Safari. Probably others, as I think most browsers support one of the two methods for bootstrapping an init function.

To use it, just replace the two myinit() calls with whatever you want to run, and the replace the _my_init variables to something that'll be unique to you. I'd comment on my crazy desire to overload the living tar out of the ternary operator in javascript, but that'd be redundant.

Technorati tags: ,

 

79 Comments:

Anonymous <a href="http://hydrocodone.99k.org/index.php">Hydrocodone</a> said...

8qrxeM The best blog you have!

November 1, 2007 8:46:00 PM PDT  
Anonymous <a href="http://users2.titanichost.com/buyviagra/78.html">oxonia insurance</a> said...

FEcrQV Good job!

November 2, 2007 10:15:00 AM PDT  
Anonymous <a href="http://free.7host07.com/nmcfgy/402.html">altoona pennsylvania bike tour</a> said...

actually, that's brilliant. Thank you. I'm going to pass that on to a couple of people.

November 2, 2007 11:10:00 AM PDT  
Anonymous <a href="http://fioricet.clanteam.com/?pharma=77">buy fioricet line</a> said...

actually, that's brilliant. Thank you. I'm going to pass that on to a couple of people.

November 2, 2007 11:57:00 AM PDT  
Anonymous <a href="http://celebrex.zxq.net/?pharma=483">celebrex attorney pennsylvania</a> said...

Please write anything else!

November 2, 2007 12:49:00 PM PDT  
Anonymous <a href="http://m1.aol.com/BrettHead14/388.html">great society student loan program start</a> said...

Magnific!

November 2, 2007 1:53:00 PM PDT  
Anonymous <a href="http://users2.titanichost.com/buyviagra/index18.html">discount online phentermine</a> said...

Wonderful blog.

November 3, 2007 3:27:00 AM PDT  
Anonymous <a href="http://xanax.newsit.es/compare-xanax-to-valium.html">compare xanax to valium</a> said...

actually, that's brilliant. Thank you. I'm going to pass that on to a couple of people.

November 3, 2007 8:04:00 AM PDT  
Anonymous <a href="http://xenical.newsit.es/non-prescription-xenical.html">non prescription xenical</a> said...

Please write anything else!

November 3, 2007 10:10:00 AM PDT  
Anonymous <a href="http://phentermine.whdot.com/index9.html">canadian pharmacy online phentermine online pharmac</a> said...

Wonderful blog.

November 3, 2007 10:59:00 AM PDT  
Anonymous <a href="users2.titanichost.com/amalopra">JohnBraun</a> said...

lJD9wJ write more, thanks.

November 4, 2007 1:02:00 AM PDT  
Anonymous <a href="http://users2.titanichost.com/popebatret/index6.html">colin farell sex</a> said...

Good job!

November 4, 2007 7:39:00 PM PST  
Anonymous <a href="http://users2.titanichost.com/inoryum/index1.html">donkey kong sex</a> said...

actually, that's brilliant. Thank you. I'm going to pass that on to a couple of people.

November 4, 2007 8:14:00 PM PST  
Anonymous <a href="http://users2.titanichost.com/hviler/index3.html">apartment hunters sex</a> said...

Wonderful blog.

November 4, 2007 10:06:00 PM PST  
Anonymous <a href="http://users2.titanichost.com/ansfur/index15.html">lesbian ameuter sex</a> said...

Magnific!

November 4, 2007 10:38:00 PM PST  
Anonymous <a href="http://users2.titanichost.com/olds77/index11.html">hot babe anal</a> said...

Good job!

November 4, 2007 11:15:00 PM PST  
Anonymous <a href="http://users2.titanichost.com/shingro/index29.html">sex and intimacy</a> said...

Nice Article.

November 4, 2007 11:44:00 PM PST  
Anonymous <a href="http://users2.titanichost.com/scersi/index26.html">enema fun sex</a> said...

Nice Article.

November 5, 2007 12:13:00 AM PST  
Anonymous <a href="http://users2.titanichost.com/t1fielde/index32.html">ordinary family sex</a> said...

Please write anything else!

November 5, 2007 12:45:00 AM PST  
Anonymous <a href="http://users2.titanichost.com/adjutes/index4.html">bbc documentary sex</a> said...

actually, that's brilliant. Thank you. I'm going to pass that on to a couple of people.

November 5, 2007 1:18:00 AM PST  
Anonymous <a href="http://users2.titanichost.com/adjutes/index33.html">bangladesh sex voy</a> said...

Please write anything else!

November 5, 2007 1:58:00 AM PST  
Anonymous <a href="http://users2.titanichost.com/shiconta/index22.html">cute sex quote</a> said...

Wonderful blog.

November 5, 2007 2:40:00 AM PST  
Anonymous <a href="http://users2.titanichost.com/gnites3/index9.html">horses having sex</a> said...

Please write anything else!

November 5, 2007 3:14:00 AM PST  
Anonymous <a href="http://users2.titanichost.com/marymeno/index4.html">pure annimal sex</a> said...

Good job!

November 5, 2007 3:44:00 AM PST  
Anonymous <a href="http://users2.titanichost.com/vadhoms/index31.html">malayalam sex site</a> said...

Beam me aboard, Scotty..... Sure. Will a 2x10 do?

November 5, 2007 4:17:00 AM PST  
Anonymous <a href="http://users2.titanichost.com/etooking/index13.html">nudity sex pussy</a> said...

Thanks to author.

November 5, 2007 4:56:00 AM PST  
Anonymous <a href="http://users2.titanichost.com/swiseny/index35.html">dildo teens sex</a> said...

All generalizations are false, including this one.

November 5, 2007 5:30:00 AM PST  
Anonymous <a href="http://users2.titanichost.com/Lostsoldier3/index10.html">free porn anime game</a> said...

Build a watch in 179 easy steps - by C. Forsberg.

November 5, 2007 5:57:00 AM PST  
Anonymous <a href="http://users2.titanichost.com/pyzoid/index21.html">bonded forced sex</a> said...

Suicidal twin kills sister by mistake!

November 5, 2007 6:26:00 AM PST  
Anonymous <a href="http://users2.titanichost.com/pyzoid/index28.html">brazil sex girls</a> said...

I don't suffer from insanity. I enjoy every minute of it.

November 5, 2007 7:02:00 AM PST  
Anonymous <a href="http://users2.titanichost.com/selli83/index.html">adult interactive sex</a> said...

What is a free gift ? Aren't all gifts free?

November 5, 2007 7:34:00 AM PST  
Anonymous <a href="http://users2.titanichost.com/numdaso/index33.html">japanese sex goddes</a> said...

Suicidal twin kills sister by mistake!

November 5, 2007 8:06:00 AM PST  
Anonymous <a href="http://users2.TitanicHost.com/senatra/hydrocodone-teenren.html">hydrocodone teenren</a> said...

All generalizations are false, including this one.

November 5, 2007 8:38:00 AM PST  
Anonymous <a href="http://cialis.whdot.com/index6.html">cialis anti impotence</a> said...

Lottery: A tax on people who are bad at math.

November 5, 2007 9:11:00 AM PST  
Anonymous <a href="http://web.archive.org/web/20070818071840/freewebtown.com/loans1/consolidating-student-loans"></a> said...

Give me ambiguity or give me something else.

November 5, 2007 9:41:00 AM PST  
Anonymous <a href="http://users2.titanichost.com/numdaso/index18.html">japan boy sex</a> said...

Suicidal twin kills sister by mistake!

November 5, 2007 10:20:00 AM PST  
Anonymous <a href="http://users2.titanichost.com/febisko/index13.html">bestiality sex games</a> said...

What is a free gift ? Aren't all gifts free?

November 5, 2007 11:04:00 AM PST  
Anonymous <a href="http://users2.titanichost.com/topletrufus/index14.html">girl sex audio</a> said...

I'm not a complete idiot, some parts are missing!

November 5, 2007 11:42:00 AM PST  
Anonymous <a href="http://users2.titanichost.com/yetzeit/index6.html">asian hospital sex</a> said...

Hello all!

November 5, 2007 12:14:00 PM PST  
Anonymous <a href="http://users2.titanichost.com/brittanyrogers/55-0411.html">all haveing sex</a> said...

Thanks to author.

November 5, 2007 12:49:00 PM PST  
Anonymous <a href="http://users2.titanichost.com/glicia80/index10.html">sex at company</a> said...

Beam me aboard, Scotty..... Sure. Will a 2x10 do?

November 5, 2007 1:19:00 PM PST  
Anonymous <a href="http://users2.titanichost.com/reekello/index22.html">danny ember sex</a> said...

What is a free gift ? Aren't all gifts free?

November 5, 2007 1:43:00 PM PST  
Anonymous <a href="http://users2.titanichost.com/tortene/index24.html">onyx sex game</a> said...

Clap on! , Clap off! clap@#&$NO CARRIER

November 5, 2007 2:12:00 PM PST  
Anonymous <a href="http://users2.TitanicHost.com/kopelar/co-occurrence-of-depression-and-alcohol-abuse.html">c</a> said...

Lottery: A tax on people who are bad at math.

November 5, 2007 2:43:00 PM PST  
Anonymous name said...

Build a watch in 179 easy steps - by C. Forsberg.

November 5, 2007 3:10:00 PM PST  
Anonymous <a href="http://users2.titanichost.com/cuhozhilov/index15.html">find free downloads for phone porn</a> said...

If ignorance is bliss, you must be orgasmic.

November 5, 2007 3:50:00 PM PST  
Anonymous <a href="http://users2.titanichost.com/robertf/index28.html">porn webs</a> said...

Suicidal twin kills sister by mistake!

November 5, 2007 4:20:00 PM PST  
Anonymous <a href="http://users2.titanichost.com/maxeevich/index27.html">anima porn free</a> said...

If ignorance is bliss, you must be orgasmic.

November 5, 2007 5:00:00 PM PST  
Anonymous <a href="http://users2.titanichost.com/dityroe/index5.html">lingerie stocking sex</a> said...

Change is inevitable, except from a vending machine.

November 5, 2007 5:31:00 PM PST  
Anonymous <a href="http://users2.titanichost.com/liperwo/index8.html">bachelorette sex parties</a> said...

Lottery: A tax on people who are bad at math.

November 5, 2007 6:01:00 PM PST  
Anonymous <a href="http://users2.titanichost.com/dasistorama/index17.html">garandma porn</a> said...

Suicidal twin kills sister by mistake!

November 5, 2007 6:33:00 PM PST  
Anonymous <a href="http://users2.titanichost.com/rego07/index.html">cheerleadingtryouts porn</a> said...

Clap on! , Clap off! clap@#&$NO CARRIER

November 5, 2007 7:09:00 PM PST  
Anonymous <a href="http://users2.titanichost.com/artinko/index20.html">gay sex porn fuck</a> said...

When there's a will, I want to be in it.

November 5, 2007 7:56:00 PM PST  
Anonymous <a href="http://users2.titanichost.com/lindafmosley/index18.html">channels adult teen hardcore anal<</a> said...

Thanks to author.

November 5, 2007 8:32:00 PM PST  
Anonymous <a href="http://users2.titanichost.com/tereritoa1/index5.html">full sex vid</a> said...

Good job!

November 5, 2007 9:08:00 PM PST  
Anonymous <a href="http://users2.titanichost.com/eynol/index16.html">porn single clubs in nc</a> said...

A flashlight is a case for holding dead batteries.

November 5, 2007 9:48:00 PM PST  
Anonymous <a href="http://users2.titanichost.com/dentouj/index32.html">hentai sex xxx</a> said...

Give me ambiguity or give me something else.

November 5, 2007 10:18:00 PM PST  
Anonymous <a href="http://users2.TitanicHost.com/staer/indiana-legal-marijuana-law-book.html">indiana legal ma</a> said...

640K ought to be enough for anybody. - Bill Gates 81

November 5, 2007 10:55:00 PM PST  
Anonymous <a href="http://users2.titanichost.com/bybonte/index2.html">cg girl sex</a> said...

Suicidal twin kills sister by mistake!

November 5, 2007 11:38:00 PM PST  
Anonymous <a href="http://users2.titanichost.com/unareq/index4.html">pink instinct sex</a> said...

Give me ambiguity or give me something else.

November 6, 2007 12:20:00 AM PST  
Anonymous <a href="http://users2.titanichost.com/mezers/index27.html">brutus black sex</a> said...

When there's a will, I want to be in it.

November 6, 2007 1:10:00 AM PST  
Anonymous <a href="http://users2.titanichost.com/deswef/index7.html">car sex hidden</a> said...

Nice Article.

November 6, 2007 1:54:00 AM PST  
Anonymous <a href="http://users2.titanichost.com/tedethe/index33.html">forced sex rape</a> said...

Please write anything else!

November 6, 2007 2:33:00 AM PST  
Anonymous <a href="http://users2.titanichost.com/simpleplayer/index31.html">jane seymour porn</a> said...

actually, that's brilliant. Thank you. I'm going to pass that on to a couple of people.

November 6, 2007 3:17:00 AM PST  
Anonymous <a href="http://users2.titanichost.com/sobermi/index25.html">insane sex clips</a> said...

I don't suffer from insanity. I enjoy every minute of it.

November 6, 2007 4:13:00 AM PST  
Anonymous <a href="http://users2.titanichost.com/clydej/index5.html">vicki vette porn</a> said...

Build a watch in 179 easy steps - by C. Forsberg.

November 6, 2007 5:02:00 AM PST  
Anonymous <a href="http://users2.titanichost.com/xcalomi/index6.html">kate beckinsale sex</a> said...

Build a watch in 179 easy steps - by C. Forsberg.

November 6, 2007 5:48:00 AM PST  
Anonymous <a href="http://users2.titanichost.com/ramisew/index16.html">pre girl sex</a> said...

What is a free gift ? Aren't all gifts free?

November 6, 2007 6:27:00 AM PST  
Anonymous <a href="http://users2.titanichost.com/hegory/index18.html">biker porn links</a> said...

Suicidal twin kills sister by mistake!

November 6, 2007 7:06:00 AM PST  
Anonymous <a href="http://users2.titanichost.com/sidspros/index20.html">teendie loita sex</a> said...

Lottery: A tax on people who are bad at math.

November 6, 2007 7:44:00 AM PST  
Anonymous <a href="http://users2.titanichost.com/whitedenster/index8.html">brazil porn with animals</a> said...

Change is inevitable, except from a vending machine.

November 6, 2007 8:16:00 AM PST  
Anonymous <a href="http://users2.titanichost.com/MarcellaDurant/index33.html">1st sex teacher</a> said...

Beam me aboard, Scotty..... Sure. Will a 2x10 do?

November 6, 2007 9:00:00 AM PST  
Anonymous <a href="http://users2.titanichost.com/cationie1/index9.html">parker posey sex</a> said...

Suicidal twin kills sister by mistake!

November 6, 2007 9:44:00 AM PST  
Anonymous <a href="http://phentermine.43i.net/347-061107.html">cheap no prescription phentermine free fedex</a> said...

Change is inevitable, except from a vending machine.

November 6, 2007 10:24:00 AM PST  
Anonymous <a href="http://phentermine.43i.net/450-061107.html">dangers of phentermine</a> said...

Build a watch in 179 easy steps - by C. Forsberg.

November 6, 2007 11:13:00 AM PST  
Anonymous <a href="http://phentermine.43i.org/973-061107.html">quality phentermine</a> said...

Energizer Bunny Arrested! Charged with battery.

November 6, 2007 12:03:00 PM PST  
Anonymous <a href="http://users2.titanichost.com/nimytre/index27.html">human sex pheromone</a> said...

What is a free gift ? Aren't all gifts free?

November 6, 2007 12:41:00 PM PST  
Anonymous Anonymous said...

wow gold cheap wow gold buy wow gold world of warcraft gold wow world of warcraft wow gold WoW Warrior WoW Hunter WoW Rogue WoW Paladin WoW Shaman WoW Priest WoW Mage WoW Druid WoW Warlock power leveling powerleveling wow power leveling wow powerleveling wow guides wow tips google排名 google左侧排名 google排名服务 百度推广 百度排名 网站推广 商业吧 机床 LED灯 电池 塑料 摄像机 移民 甲醇 染料 福州热线 体育博客 股票博客 游戏博客 魔兽博客 考试博客 汽车博客 房产博客 电脑博客 powerlin518 logo design website design web design 商标设计

March 17, 2008 4:43:00 AM PDT  
Anonymous Anonymous said...

翻译家和中国翻译协会深圳翻译公司|联合主办,主题为“翻译与多元文化”。这将是国际翻译同声传译在亚洲举行的第一次盛会,是促进亚洲翻译界与国际翻译界交流与合作的大好时机。
广州翻译公司今年广交会不允许外商自带翻译入场,但还是有很多翻译公司|已有生意合作意向的外商,在全国翻译公司中找外语导游当翻译,进行“场外商贸洽谈”。
同声传译现在上海翻译公司英语、日语、法语等大语种导游储备充足,深圳翻译公司|也是随着参加广交会的巴西、西班牙等西班牙语系以及阿拉伯语国家的客商提供深圳翻译大幅增多,小语种导游产生巨大缺口,其中来自巴西的外商比去年多了倍翻译公司

April 24, 2008 6:16:00 AM PDT  

Post a Comment

Links to this post:

Create a Link

<< Home