Author Archive

Easy Pop-Under

Pop-up advertising is nothing new to the web; we’ve been fluently closing free iPod offers for years now.  However, the latest breed of these attempts to be less intrusive by popping under the current browser instead, with the intention of you not seeing the ad until you’ve closed the browser window.   Fellow Mac users probably see the fault in this logic (since after a typical browsing session, you’d hit Apple-Q, which kills all browser windows at the same time), but nevertheless the technique is growing in popularity, and you might be wondering how to do it.

Fortunately, this is a VERY simple technique which can be cross-browser friendly with only two Javascript commands:

// specify the destination and window size
function popUnder(url, height, width) {

     // spawn the new window using blur() to attempt to
    // force the window into the background
    window.open(url,
        'width='+width
        +',height='+height
        +',left=200,top=200'
    ).blur();

     // force this window into the foreground (to cover
    // any browsers that were unresponsive to blur()
    window.focus();
}

And that’s it — you can now be on the road to being a more subtle nuisance. =)

Comments (1)

Skipping an Abstract Generation

One of the issues of working with an existing OOP codebase is that the original author may have programmed abstract classes with a fixed class depth in mind. For example:

abstract class animal
{
    abstract function speak();
}

class dog extends animal
{
    function speak() {
        print "woof";
    }
}

class cat extends animal
{
    function speak() {
        print "meow";
    }
}

All is well in this quadroped example, but what if you decide you’d like to break cats down into seperate sub-species, but leave dogs as is? Presuming that you already have hundreds of animal extension classes written, it would be tedious to reconfigure the abstract base class to handle this exception. Luckily, abstract requirements can skip a generation:

abstract class animal
{
    abstract function speak();
}

class dog extends animal
{
    function speak() {
        print "woof";
    }
}

abstract class cat extends animal
{
    // some general cat methods
}

class kitten extends cat
{
    function speak() {
        print "meow";
    }
}

class lion extends cat
{
    function speak() {
        print "roar";
    }
}

The intermediate class needs to be declared as abstract to indicate that any requirements of both itself and its parent(s) are to be passed to its child. Because the child classes, such as kitten and lion, contain the speak() method, they have satisfied the abstract requirements of the grandparent class, animal. Meanwhile, the dog class still functions as before.

Leave a Comment

Follow

Get every new post delivered to your Inbox.