Customize Pop-up Image Windows

Have your thumbnails open slick, customizable pop-up windows.

There are times when it pays to have a compulsive personality, which you probably like to call “attention to detail.”

On eBay, for instance, “attention to detail” makes your listings look more professional and will likely compel you to more carefully describe and photograph your items, both of which are good ways to inspire trust with your bidders [Hack #8] and set a proper expectation [Hack #50] . But why stop there?

If you’re including clickable thumbnails [Hack #77] or video clips [Hack #58] in your listings, you can customize the pop-up windows that appear using JavaScript.

Unfortunately, this is not as easy as it sounds. On most other web sites, you could do this quite simply with the window.open JavaScript statement, but as described in the Preface, eBay displays the “Your listing cannot contain JavaScript” error if you try to submit a description containing the window.open statement in any context.

The Code

Instead, a slightly more complex script is needed. Start by placing the following JavaScript code in the beginning of your listing description:

<script language="JavaScript"> 
     var w = window;
     var whack = w.open;
     function ohack(url, name, attributes) { return (new Object()); } 
 w.open ...

Get eBay Hacks, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.