Javascript Get Browser
Posted by tech on
September 22, 2008
Getting the browser that you are using using Javascript can be important in some cases. Like when reading or setting an element’s property, browsers like IE and Firefox both have different ways to do them. Take for example creating a hyperlink using Javascript. To create the text of the hyperlink, IE uses its proprietary innerText property while Firefox uses textContent (although the specific browser will just ignore the property that it cannot recognize, I feel it’s nice to use browser detection to fully ignore the property even if no error will be thrown). Using the function below can be pretty useful in doing conditional statements on which property to apply to an element. The function is custom made, you can modify it if you wish since my only concern was having to know if the browser was IE or not.
1 2 3 4 5 6 | function getBrowser() { var sBrowser = navigator.userAgent; if (sBrowser.toLowerCase().indexOf('msie') > -1) return 'ie'; else if (sBrowser.toLowerCase().indexOf('firefox') > -1) return 'firefox'; else return 'mozilla'; } |
tags: browser, javascript
2 Comments
Blogger or WordPress?
Posted by tech on
May 2, 2008
These 2 are perhaps the most famous blog sites out in the open. You could ask the next question, which one is better? My answer, depends. If we talk about monetary purposes, and you have no plans to purchase your own hosting, go with Blogger. It allows you to place AdSense ads within your blog sites unlike the WordPress site. But hey, nothing’s free in this world anymore. Blogger gets a small percentage of the money that you earn whenever someone clicks on your ads. This is quite understandable as we are using Blogger resources for our blogs, it’s natural Blogger gets something in return. You can use WordPress with AdSense only if you have your own hosting and domain. In terms of ease of use and setting up, Blogger wins over WordPress big time. You would have to have at least a bit of techie knowledge when using WP. Blogger’s user interface makes it very easy for users to place content and change their layout to name a few. I was so pissed when I first started using WP after I got my own hosting and domain. It’s sooooo unfriendly. Until now, I still hate WP but I have no choice. In my experience, I had a very hard time navigating the WP user interface when I first used it. It is PHP based, so you must at least know something about this in order for you to tweak your way around. It took time, but I finally did finish setting up everything I need with my blogs using WP. Remember, if you’re non-techie, I strongly advise you to use Blogger for blogging. You won’t have a hard time using it even when you’re still new to it. If you opt to use WP, good luck. You’re on your own.
Donations appreciated. Every little $ helps. Or click Google +1tags: blogger, php, wordpress, wp
2 Comments
PHP How To Send HTML Email with SMTP Authentication
Posted by tech on
April 28, 2008
Here’s a code snippet on how to send HTML email with SMTP authentication using PHP. You would have to download a library called PHPMailer as the mail() function of PHP does not support SMTP authentication. There is also other class that must be in the same location as class.phpmailer.php in order for the mail sending to work, smtp.phpmailer.php.
require_once("class.phpmailer.php");
$mail = new PHPMailer();
$mail->IsSMTP(); // telling the class to use SMTP
$mail->IsHTML(true);
$mail->SMTPAuth = true;
$mail->Username = "username"; // your SMTP username
$mail->Password = "password"; // your SMTP password
$mail->Host = "smtp.host.url"; // SMTP server
$mail->From = $from;
$mail->AddAddress($to);
$mail->Subject = $subject;
$mail->Body = $body;
if(!$mail->Send()) {
echo 'Message was not sent.';
echo 'Mailer error: ' . $mail->ErrorInfo;
} else {
echo 'Message has been sent.';
}










