homepage Welcome to WebmasterWorld Guest from
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member
Home / Forums Index / Hardware and OS Related Technologies / Website Technology Issues
Forum Library, Charter, Moderators: phranque

Website Technology Issues Forum

Best way to do a pop up
without getting it blocked

 7:26 pm on Jan 6, 2006 (gmt 0)

I dont like pop ups, but the company I work for wants one.

Whats the best way to do it without getting it blocked?


Longhaired Genius

 7:34 pm on Jan 6, 2006 (gmt 0)

Why do you care if it gets blocked? You don't like pop-ups.


 10:16 pm on Jan 6, 2006 (gmt 0)

Why do you care if it gets blocked? You don't like pop-ups

Next time please add some value to your post.

You have to make it user initiated. Meaning, the user has to click on something to make it open. If you just pop up a window without a user performing an action, those are the culprits that blockers feed on. Just about every blocker I've seen/used does a good job of letting user initiated clicks happen.


 11:40 pm on Jan 6, 2006 (gmt 0)

Could I get a code example of how to do it please?


 11:41 am on Jan 7, 2006 (gmt 0)

All you need to do is write either a little javascript: onClick="window.open(URL,title,features)" to do it.

OR you can use the old trusted method: <a href="url" target="_blank"> which will also open it in a new window.


 8:19 pm on Jan 9, 2006 (gmt 0)

One little problem: target="_blank" is deprecated and 10% of users have Javascript turned off. How do you get around that? Simple:

<a href="url" onClick="window.open('url','title','features'); return false;">

Fully valid and, most importantly, does annoy a user with JS disabled by making an end run around his settings. If the user has JS enabled and your popup doesn't get blocked, it runs the JS and opens the new window and returns false, so it basically cancels the click and the current page stays the same.

If the user has JS disabled, then it doesn't run the code that returns false, treats the click as a normal click and opens the "popup" as a regular page (which is what the user wants - that's why he's disabled JS).

If JS is enabled but the popup gets blocked, it still returns false and nothing happens, though in general, in Firefox at least, the popup will open (user-initiated) and if it doesn't, the user will get a notice asking if he wishes to make an exception for your excellent site.


 9:46 pm on Jan 9, 2006 (gmt 0)

I don't like that target=_blank is deprecated. Nice and clean code to deal with.

I still use it and it validates as transitional.

Works well with my 8-tracks too.


 5:38 pm on Jan 10, 2006 (gmt 0)

You may not like it, but... I used to feel the same way, but the logic is this:

- target="_blank" forces a client to open a new window.

- opening a new window is a client-side behavior that should be achieved with client-side scripting that can be controlled by the client (or user of the client) if desired.

- using HTML to do this mixes models and overrides client controls.

It is the rough equivalent of using HTML to control font size and font face, rather than CSS, but I think worse, actually, because it doesn't merely force a presentation on the user regardless of whether they have an overriding stylesheet, but actually forces a behavior on the user for which no current browser offers an override.

Global Options:
 top home search open messages active posts  

Home / Forums Index / Hardware and OS Related Technologies / Website Technology Issues
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved