Weird Thoughts From Eric's Head

Tags - Categories : All | AJAX | BUSINESS | PERSONAL | PROGRAMMING | BOOK REVIEW

Old Joke
While going through his wife’s dresser drawers, a farmer discovered three soybeans and an envelope containing $30 in cash. The farmer confronted his wife, and when asked about the curious items, she confessed: “Over the years, I haven’t been completely faithful to you.”

“When I did fool around, I put a soybean in the drawer to remind myself of my indiscretion,” she explained.

The farmer admitted that he had not always been faithful either, and therefore, was inclined to forgive and forget her few moments of weakness.

“I’m curious though,” he said, “Where did the thirty dollars come from?”

“Oh that, ” his wife replied, “Well, when soybeans hit ten dollars a bushel, I sold out!”

How are people defeating pop up blockers?
I been asked this question and they are really not defeating a pop up blocker. If you go to a site and just view it, the pop up window will not happen. If you exit the site, it does not happen. So how come sometimes the pop up window is there?

The first thing you need to realize is the a popup window is only allowed by this piece of software if it is initialized by the user. AKA: an action has to be performed.

Therefore the better question that you should ask is how are links performing two actions instead of one?

It is rather simple to do and people have done it before pop up ads were the rage.

Now lets break this whole thing done.

We have a regular link that opens a page:

<a href="http://www10.brinkster.com/A1ien51">JavaScript</a>
Now lets add an onclick handler that opens up a new window. Now if you click on that link, a pop up should be on top of the page and page should change location.
<a href="http://www10.brinkster.com/A1ien51" onclick="newWin = window.open('http://www.google.com');return true;">JavaScript</a>
The return true also helps browsers out with opening the link. Most likely most browsers will do both functions without the return false, but it is better to be safe.

Now IE normally shows the pop up window on top and Mozilla/Firefox normally shows the pop-up window on the bottom. So if you want the pop up window on the bottom (aka pop-under) you can just make the window loose focus and focus the parent.
<a href="http://www10.brinkster.com/A1ien51" onclick="newWin = window.open('http://www.google.com');newWin.blur();window.opener.focus();return true;">JavaScript</a>
You can make the pop up window on top by just reversing the process
<a href="http://www10.brinkster.com/A1ien51" onclick="newWin = window.open('http://www.google.com');window.opener.blur();newWin.focus();return true;">JavaScript</a>
Now I know I will get hate mail for doing this, but if you search Google you will find this answer. It has been around a long time and there is no way this can be stopped by a pop up blocker if the user allows this type of pop up window. Therefore if you see a site that uses pop up windows, then you should just learn to live with them or do not go to the site. I see it as a wrist exercise!

Tomorrow I will try to blog about the new generation of "pop-up" windows and why it is hard to defeat them.

Eric Pascarello
Moderator of HTML/JavaScript at www.JavaRanch.com
Author of: JavaScript: Your Visual Blueprint for Dynamic Web Pages




Add a comment

Title
Body
HTML : b, i, blockquote, br, p, pre, a href="", ul, ol, li
Math Quiz 2 + 6 = (Helps stop blog spam)
Name
E-mail address
Website
Remember me Yes  No 

E-mail addresses are not publicly displayed, so please only leave your e-mail address if you would like to be notified when new comments are added to this blog entry (you can opt-out later).

TrackBack to http://radio.javaranch.com/pascarello/addTrackBack.action?entry=1104937113000