Search

No-Kill Pop Box (Instead of Popups)

6 min read
1 views

Planning and Designing Your No‑Kill Pop Box

When a site’s visitor sees a pop‑up, a lot of ad‑blockers and popup blockers step in and hide it. That means a lot of useful messages and offers disappear before the user sees them. The trick with a No‑Kill Pop Box is to wrap the content inside a simple HTML table that sits in a positioned div. The table renders even if JavaScript is disabled, but closing the box still relies on a small script. That gives you the best of both worlds: the popup still shows when the browser refuses JavaScript, and you can still offer a convenient “Close” link that works when JavaScript is available.

First, sketch out exactly what the pop box will look like. Do you need a header, a body, a footer, or maybe a close button in the corner? Put the final design into a plain HTML table. Table cells can hold text, images, or any other element you need. By keeping the content in a table, you avoid the browser inconsistencies that come from trying to style a layer’s borders or padding directly. The table will also keep the layout tidy and predictable across browsers.

Use the following example to get a feel for the structure. In this snippet the outermost table holds the actual message, while a single td contains the close link. Replace the text and images with your own as needed.

Prompt
<table border="0" cellpadding="0" cellspacing="0" width="300"></p> <p> <tr></p> <p> <td style="background:#e0e0e0; padding:10px"></p><strong>Heads‑up!</strong> We have a special offer just for you.</p> <p> </td></p> <p> </tr></p> <p> <tr></p> <p> <td style="text-align:right; padding:5px"></p> <p> <a href="javascript:CloseNoKillPopBox()">[Close]</a></p> <p> </td></p> <p> </tr></p> <p></table>

Once you have a table that looks how you want, keep a note of its exact pixel width and height. You can measure the dimensions with a tool such as

Prompt
function CloseNoKillPopBox() {</p> <p> var box = document.getElementById('BetterThanPopup');</p> <p> if (box) {</p> <p> box.style.visibility = 'hidden';</p> <p> }</p> <p>}

Notice the visibility change. Setting it to hidden keeps the div in the document flow, which means any future content can re‑flow underneath if needed. If you prefer to remove it completely, use display: none instead.

Because the box should still render when JavaScript is disabled, you’ll want to add a <noscript> message to explain why the user can’t close it. The snippet below can be placed inside the div or in the page’s body; it will appear only when scripts are turned off.

Prompt
<noscript></p> <p> JavaScript must be enabled to close this box.</p> <p></noscript>

Suggest a Correction

Found an error or have a suggestion? Let us know and we'll review it.

Share this article

Comments (0)

Please sign in to leave a comment.

No comments yet. Be the first to comment!

Related Articles