How to Create Javascript Catfish Sliding Promotions
An effective way to advertise or promote a product is the Catfish pop-up, so called because it lies on the bottom of the browser. Less annoying than fullblown pop-ups and to me much better than adverising embedded within content. I've mocked up two example pages a transparency example and an example form.
Sitepoint
As far as I know catfish pop-ups were first implemented on Sitepoint and detailed in The Catfish—Part 1 and Set Us Up The Catfish—Part 2: SlideMe articles.
My Implementation
I've enhanced (re-written) the implementation to use an iframe so instead of embedding the promotion within your main content (The Sitepoint implementation uses a div at the bottom of the markup), you can place the promotion code in a separate HTML file.
An iframe will also help the page load faster and the javascript is light at <5kb (<3kb for non IE6) not including the size of your iframe content.
The iframe will allow you to use forms within your promotion which will act independently of your main content; your promotion could be on another site altogether.
Usage
The download (zip) contains the examples from above and implementing your own catfish should be fairly straight forward. I've tried to make the amount of markup you need to add to a page as lightweight as possible but the minimum I've been able to get it down to is the code example below. IE6 does not support the CSS style position:fixed, so a workaround had to be introduced.
The Markup
Place the following between your <head> tags.
There's some conditional code here to get it to work in IE also note the use of the script defer which is a way of getting IE to delay script execution until the DOM has formed.
Calling catfish()
You can call catfish and configure all the options (from the 4th line in the markup above).
or, allow the script to default the scrolling speed and delay for you.
| Parameter | Description |
|---|---|
| url |
The url of the content you wish to display. |
| height_in_px |
The height of the content. |
| start_delay_in_ms |
The number of milliseconds before the content starts to scroll into
view. (default is 2000ms) |
| speed_in_ms |
The time in milliseconds before the content is moved increment_in_px
pixels. (default is 25ms). |
| increment_in_px |
The number of pixels the content is moved every speed_in_ms
milliseconds. (default is 5px) |
Closing options
You have two options when allowing the user to close the catfish temporary or permanent, temporary will re-open the catfish when the user refreshes the page or goes to another page with a catfish.
Permanent will set a cookie and not re-open the catfish for that user (unless they clean out their cookies).
Temporary close markup for your catfish :-
Permanent close markup :-
And Finally
I've only been able to test the implementation on IE6 and Firefox, if someone could let me know how well it runs on Safari and Opera that would be great.
If you do implement some catfish pop-ups please let me know so I can add a few more examples to this article.

22 Comments
I'm sure i'll be using this technique in the future, I'll post again with details when I do!
When I test this using the form-test.html, I can get catfish to appear fine in both IE and Firefox. However, when I try to use the same exact code in a wordpress page within the same directory that the form-test.html is in, I get the following error: "Error: catfish is not defined" and the error is referencing the catfish iframe call: catfish('form-test/popup.html', 100... Any ideas? Thanks in advance!
Could be that either the js is not loading, try using the full path to the js file in the 'script' section i.e. http://www.example.com/catfish/catfish.js assuming you've placed the js in a folder just off your root domain.
Or,
Fully qualify the link to the form-test page, i.e. http://www.example.com/form-test/popup.html You can send me a link to your site on ian dot purton at gmail dot com. and I'll take a look.
jerks and staggers onto the screen...very odd...
will test on a mac in a little bit..
It works perfectly fine in Safari (surprisingly).
Although only slightly familiar with JavaScript, I tried implementing the Catfish technique as detailed above in a website I am currently working on and achieved what I had planned, but not without shortcomings: the page that featured it was rendered in such a way as to be left without vertical scrollbar in Firefox 2, the content out of the viewport thus being cut off and inaccessible.
In addition, the Firebug extension for Firefox kept reporting a JavaScript error to the following effect:
document.getElementsByTagName("body")[0] has no properties
document.getElementsByTagName('body')[0].innerHTML + '';
What could be done about this?
Have you got into Apollo and Flex yet?
Its the future you know !!
Don't get left behind, you might get rail roaded, Ruby is dead .
Anth.
There is a performance problem, in that the catfish will start to display even if the associated images are not ready yet. To fix this you'll need to pre-load the images with javascript. A quick google found this link http://www.pageresource.com/jscript/jpreload.htm
Is there any possibility you could write a cookie version of the original sitepoint div version?
A quick question (and mentioned by others): would you do a favor and implenent a session method so that if someone opts out of catfish, it is not shown on subsequent pages?
Thanks, steve
I have the theme, but on my home page it just shows the whole post for every post. I want to just show the excerpt like you have and with a read more button to open the post up.
thanks
http://www.iwaquebec.com/images/catfish.jpg
Cheers,
Chris Campbell
Also, For some reason it doesn't play nice when the page has a background image that's centered and bottom justified. It also doesn't display all the content for some reason. I had this script working on this page before using the script I got off sitepoint, though once I tried using iframes it doesn't display all the content and the bg image is way off as well. you can see this in action here: http://www.campbellcanes.com/indextest.shtml
A point in the right direction would be awesome.
chris
Leave a Comment