Set element’s CSS min-height using JavaScript minHeight
Recently I have been doing a lot of work on new sites that incorporate fixed-position footers (similar to the Facebook chat bar). A few examples sites are: Power Core USA and Douglas Stevens, MD (both of which I coded, graphic design by Brand Chemist). I ran into an issue with Power Core layout where the main content borders were not reaching the footer on larger displays in pages with small amounts of content (eg: not enough to activate scrollbars). So I ended up writing a quick JavaScript function to set the minHeight property of the DIVs causing the issue. Read more
Future proof PHP class constructer compatible with php4 and higher
Since there was no real viable reference to either confirm or oppose my methods, I figured this may help someone else that is trying to make sure they don’t have to change their code based on the installed PHP version.
As most of us already know, initializing a new class object in PHP4 required the constructor to have the same name as the class.
class Myclass {
function Myclass()
{
echo 'Myclass initialized';
}
}
Then __construct() was introduced in PHP5.
class Myclass {
function __construct()
{
echo 'Myclass initialized';
}
}
Now you may be thinking “I’ll just use this from now on”. I however have to write for multiple versions of PHP4/5 and must keep backwards compatibility in mind (at least for now). Here is what I use to make sure it works on all versions of PHP that currently support object-oriented programming or OOP. Anything earlier than PHP4 and I simply tell the client to find a new host, lol. Read more
Javascript Image Preloader with Image Swapping Function
In this post you will find a simple image swapping function that will work for all images that need a hover effect.
The ‘img’ argument is required of course. I can either be a reference the the image object itself (eg: swapImg(this)) or a string (eg: swapImg(‘ImageID’)) if calling the function from somewhere other than within the <img> tag. If no arguments are passed, it aborts execution. If a string is passed, we first make sure that getElementById is supported. Then we check to make sure the ID passed is valid, of not we return.
After ‘img’ has been checked and confirmed, we move on to the 2 optional arguments. The ‘find’ argument (case-sensitive) indicates the string we are looking for at the end of the image src attribute. If the string is found, we know that the image is currently in the ‘over’ state and we replace ‘find’ with ‘repl’ to return the image back to it’s normal state. On the other hand, if ‘find’ is not located, we rebuild the src attribute and insert ‘repl’ at the end of the image url (before the file extension) to activate the hover state. Read more
OpenCart Checkout With Virtual Merchant Gateway
I have finished writing a payment module for the Virtual Merchant gateway to use with OpenCart 1.4.9.1. If you need to integrate Virtual Merchant with OpenCart, this is your solution. Why write it yourself when it’s already done?
Virtual Merchant gateway payment module for OpenCart
Disable/Hide Internet Explorer’s Compatibility View Button
If you are an active web developer, you have likely been plagued by Internet Explorer’s Compatibility View button. I have seen so much poor advice about disabling this feature in IE7+. Post after post after post people suggest forcing a specific version for emulation. Haven’t we all learned that allowing IE to dictate how we code a page is a BAD idea?
If you properly code your pages to use standards and a proper document type definition or <!DOCTYPE>, why does IE persist in not doing what it’s told and letting visitors make potentially baddecisions. A user can accidentally click the Compatibility View button or have compatibility mode always enabled by default (OMG!). If you want to make sure IE or the user doesn’t dictate how you code, or how the layout is butchered by compatibility view, add the following to your <head> section…
