Welcome to WebmasterWorld Guest from 23.20.238.193

Forum Moderators: phranque

Message Too Old, No Replies

Best way to do a pop up

without getting it blocked

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

10+ Year Member



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

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

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

10+ Year Member



Why do you care if it gets blocked? You don't like pop-ups.
10:16 pm on Jan 6, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



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)

10+ Year Member



Could I get a code example of how to do it please?
11:41 am on Jan 7, 2006 (gmt 0)

WebmasterWorld Senior Member txbakers is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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)

WebmasterWorld Administrator ergophobe is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



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)

WebmasterWorld Senior Member txbakers is a WebmasterWorld Top Contributor of All Time 10+ Year Member



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)

WebmasterWorld Administrator ergophobe is a WebmasterWorld Top Contributor of All Time 10+ Year Member Top Contributors Of The Month



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.

 

Featured Threads

Hot Threads This Week

Hot Threads This Month