Adding html tags in the mailto body?

After much research, at least at this point there is no way to include html tags in the mailto body. If a particular email client plays nice then you are in luck, otherwise there is no standard, or cross email client way to include html tags in the mailto body. During my research (just googling around…), I found this nice tool that can help construct the mailto link. You simply need to fill in the to, cc, subject, and body, then the mailto link will be generated for you. Check it out at http://jscode.com/generators/mailto_generator.shtml ...

February 21, 2012 · 1 min · birdchan

pre-filling an email in the email client using javascript

Sometimes people prefer to use their own email client application to add their own styling. That’s when we will need to pass the relevant email content to the email client. It’s simple enough so I won’t explain much. Here I am passing the email info from php to javascript. $email_to = "johnsmith@somewhere.com"; $email_subject = "some email subject"; $email_body = "some long text, will need to escape this."; //$email_body = urlencode($email_body); // not this one, empty spaces will turn into +'s $email_body = rawurlencode($email_body); // this will encode correctly $email_url = "mailto:$email_to?Subject=$email_subject&Body=$email_body"; $('#email_btn').click(function(){ // bind to the email btn window.location = "$email_url"; }); That’s it! Now upon pressing on the email button, the user’s default email client should pop up a new email window with the fields pre-filled. ...

February 21, 2012 · 1 min · birdchan

using js to open links in current window, new window, or in the background

There are times to open links in the current window, sometimes in a new window, sometimes in background. Here is how to do it. function open2(url, opt){ if (opt == 0) // current window window.location = url; else if (opt == 1) // new window window.open(url); else if (opt == 2) // background window {window.open(url); self.focus();} } The syntax is a bit confusing, I guess these should be standardized in the future. ...

February 21, 2012 · 1 min · birdchan

remove the ok button in jeditable select

The default sample code for in jeditable has an OK button. That ends up requiring one more click to pick a value from a dropdown. $('.editable').editable('http://www.example.com/save.php', { data : " {'E':'Letter E','F':'Letter F','G':'Letter G', 'selected':'F'}", type : 'select', submit : 'OK' }); To take away that OK button, just take out that “submit” attribute. Magically, after picking a value from the dropdown the value gets updated. Kudos to the contributor who enabled this feature. ;) ...

February 20, 2012 · 1 min · birdchan

The practical alternative to work

See more at: Coding Horror:

February 20, 2012 · 1 min · birdchan

qTip2 setting background color

I have been playing with qTip2 for a bit. Once you figure out the code to popup a tooltip, the next thing you think about is probably styling. I was looking for ways to set the background color from the default white to something else. If you give your qTip2’ed content, say a div, the background color yellow, you will still see white padding around your div. To take away that white border or padding, Have the following styling. ...

February 17, 2012 · 1 min · birdchan

The "secret" of flying cheap

FRONTLINE “Flying Cheap” | Sneak Peek 1: Who’s Flying Your Plane? | PBS [youtube &w=640&h=360] Watch the full video (about an hour long) at: http://www.pbs.org/wgbh/pages/frontline/flyingcheap/view/?autoplay If you ever shop for cheap air tickets, I would highly recommend you to watch the full video. You really need to know who are the people who are actually flying your plane. ...

February 14, 2012 · 2 min · birdchan

Jeremy Lin 林書豪

[youtube &w=640&h=360] [youtube &w=480&h=360] 9 Lessons Jeremy Lin Can Teach Us Before We Go To Work Monday Morning http://www.forbes.com/sites/ericjackson/2012/02/11/9-lessons-jeremy-lin-can-teach-us-before-we-go-to-work-monday-morning/ 在週一上班前,林書豪教我們的九堂課 http://www.inside.com.tw/2012/02/12/9-lessons-jeremy-lin-can-teach-us-before-we-go-to-work-monday-morning

February 12, 2012 · 1 min · birdchan

The "select all" checkbox to select all checkboxes

Below is what you need for a “select all” checkbox to toggle the rest of the checkboxes. Below assumes your checkboxes all have the name “my_chkboxes[]”. $('#my_select_all').click(function(){ $("input[name='my_chkboxes[]']").each(function (index, el) { if ($('#my_select_all').is(':checked')) { $(el).attr('checked', 'checked'); }else{ $(el).attr('checked', false); } }); });

February 11, 2012 · 1 min · birdchan

Select the last option of a drop down

Say you have a list of drop down select options and you want to pick the last option by default when the page loads, with jquery this is how to do it. $(document).ready(function() { $('#my_select option:last-child').attr('selected', 'selected'); }); Below is how you get the the value of the first, last, and the nth options. var option_first = $('#my_select option:first-child').val(); var option_last = $('#my_select option:last-child').val(); var option_nth = $('#my_select option:nth-child(0)').val();

February 10, 2012 · 1 min · birdchan