January 10, 2007

How to prevent pop-up blocking in Firefox

Using navigateToURL() method causes pop-up blocking feature activation in Firefox since Flash is a plug-in:

Use window.open() JavaScript method instead. I have created URLUtil class with openWindow() static method to make it easier:

Now my blog could be opened in a new browser window this way:

43 comments:

Unknown said...

Brilliant, I have been looking for this for some time now. Works perfectly now.

Thanks.

Anonymous said...

Yes, Brilliant. even I was looking for this. hats offman. you rock...

Anonymous said...

I love you man! Big big help for me. Thanks!

Anonymous said...

Much obliged for the work-a-round!

Anonymous said...

Been looking for a fix for this for a while - THANK YOU!!!!!

Unknown said...

This is still getting blocked for me in Firefox 2.0.0.6 (Windows Vista) with Flash Player 9,0,45,0. Any ideas?
Reference url

Unknown said...

ian, I have no ideas. Probably Firefox 2.0.0.6 has some strict pop up blocking policy that results in this behavior.

Unknown said...

I'm thinking firefox isn't the problem since 2.0.0.6 is the latest public release and I'm sure more people would have the same issue.

Anonymous said...

theres no reason to believe that this will be anymore reliable than the built in method, since it calls javascript window.open. One would think that window.open would be blocked by any self respecting popup blocker.

Unknown said...

Kak dila? (Or should I say Prived?)

Question for you...

I've utilized your methodology for some in-house applications. I've found in order for it to work I had to add the "allowScriptAccess='always'" attribute.

I've ran into a situation where we are providing a swf to be hosted on an automated system and I have no control over their method of object/embed. Because of that, the externalInterface.call failes to elicit any action in response.

Thus when the user clicks it does nothing. Or I can go back to navigateToURL and if the user clicks they are caught by the built in pop-up blocking.

I don't mind the blocking of automated pop-ups, but it's annoying when a user clicks a link spot and goes no where.

:(

Unknown said...

Both "Kak dela" and "Privet" are ok. :)

Yes, probably, you are right and there is no way to open pop-ups at all when you have no control over the HTML wrapper. Thus my solution doesn't fix the problem completely.

Денис said...

дякую, допомогло =)

Anonymous said...

Works excellent for IE and FF. But now - using this method - opening a new window on Safari (v3.0.4) and Opera (v9.24) is blocked on my computer. Any suggestions ?

Unknown said...

I have no idea, because I have not tested in Opera and Safari. Probably, those browsers have stricter policies.

Anonymous said...

I've tried this with great results. As far as the Safari/Opera problem, you can run an additional ExternalInterface which gathers the browser info, then using a conditional, only use the class instance if the user's browser is Firefox. I wrote my workaround solution here -> http://flexgraphix.com/blog/?p=16.(I hope this link is OK)

Unknown said...

I used this tips last year and it was working perfectly. But I tried again this week and it didn't work.
Is it still working for you with FF 2.0.0.11 and flash player 9,0,115?

Anonymous said...

Hi there. I have the same issue. What I just discovered though is that your fix works in player 9.0.45.0 but not in 9.0.115.0. Very strange.

Anyone any ideas why this is? What did they change on the new version that stopped it from working?

Anonymous said...

I am also having the same issue with FF 2.0.0.11 and flash player 9.0.115. Please help!

Leo

Anonymous said...

I am having issues with Flash popup blocking for Flash-in-Flash on 9.0.115.0 and it appears that Adobe broke something on this release.

Anonymous said...

Great news! I figured out the cause of my 9.0.115.0 Firefox popup blocking issue that didn't affect earlier versions of the Flash plugin:

You have to make sure the src of the embed statement is a FULL URL. e.g. instead of embed src="./mymovie.swf", do embed src="http://..../mymovie.swf"

Not sure if that will work in your case, but it worked for me.

I reported this issue to Adobe, and I'll be sending them an update with the new information.

Anonymous said...

My bad, it's actually wmode set to "window" that causes popups to be blocked in .115 in Firefox. I noticed that besides the URL between the page that had popups blocked and the page that didn't, wmode was also differently, so I had gotten confused over what was different.

Therefore, if you don't want popups blocked in .115, set wmode to opaque or transparent.

Unknown said...

Excellent NetDragon, if I put wMode="opaque", it works perfectly.
Thanks for this tips.

Unknown said...

Has this method stopped worked again?

I have set wmode=opaque (also tried transparent) and I have tried both navigateToUrl and the javascript method mentioned in this article, but I still get the popup-blocker?

Unknown said...

I solved my problem, I was using MouseEvent.MOUSE_DOWN, but it only works with MouseEvent.CLICK.

Alfred said...

This is really annoying. It works fine to set wmode in order to prevent popup-blocker for version 9.0.115.

However, in previous versions of Flash Player 9 there was another bug where fullscreen mode did not work if wmode was set.

In other words, either you have your external links blocked in 9.0.115 or you have to live without fullscreen mode for older version 9 players.

Anybody got a clever workaround?

Alfred said...

Alright -- couldn't wait for your clever solutions so I invented a dumb one by myself.

Those of you familliar with the SWFObject method of embedding flash on a page can use my solution.

Others should really check out SWFObject. http://blog.deconcept.com/swfobject/

SWFObject nicely checks the Flash player version for you and hence you only need a minor tweak to solve the problem.

The solution of course is to set wmode to either opaque or transparent for users with 9.0.115 but leave the property out otherwise.

In your SWFObject code -- just add these lines below the line where the SWFObject-object is created.

Replace "s1" width whatever your SWFObject is called.

var sVersion = s1.installedVer.major+"."+s1.installedVer.minor+"."+s1.installedVer.rev;
if(sVersion=="9.0.115"){ s1.addParam("wMode","opaque"); }

Anonymous said...

Thanks Netdragon and Alfred. You're solutions are a life saver :)

Alfred said...

In an attempt to save another life I realised that I have updated my solution since posting here.

Apparently IE7 doesn't like the wmode parameter (which really should have nothing to do with it in any browser) even if Flash Player is in version 9.0.115.

So take my solution from my last post and add a check for explorer.

If the Flash Player version is 9.0.115 and the browser is NOT Explorer -- set the wmode parameter to transparent or opaque.

Unknown said...

Hello,

thank for your tip but I fear I have another problem.

If wmode is set to opaque or transparent we have the old bug of firefox changing the value of what is typing in a form. (for example with a french keyboard, the @ is turned to à).
There is still the solution to listen to the keyboard and change every letter when it is inserted but it's really something just to open a new window...
Does someone have new tip for this ?

Anonymous said...

I'm just coding a static button here, but you could make this a dynamic function easily:

ExternalInterface.call("window.open('inspiration_gallery.html', 'InspirationGallery', 'height=600, width=700')");


Doing it this way opens a new window in IE and FF. It doesn't work in Opera, Safari I don't know. I'll have to test those and write a work around for those browsers.

I am using it at greencraftpdx.com. I've got other issues to take care of, but it's getting there.

Kyle Kienitz

Anonymous said...

The implementation above works for buttons but unfortunately doesn't prevent FF from blocking an HTML style link in a text area. I'm assuming that FF doesn't generate a click event for HTML links and so cannot recognize that the URL request is user generated, blocking it even if it's called through the external interface.

I'd love to know if anyone has come up with a work-around for this issue.

Michał said...

Hi

With new Firefox 3 beta 5 it makes browser to generate an alert and script seems to be hanging. new page opens but nothing can be seen.

Anonymous said...

With Firefox 3, when flash is fullscreen it doesnt work...

Anonymous said...

is there any way to send the data property of the URLRequest object using this javascript method ?

Elaine Chong said...

I use URLRequest.url
but the the site didnt show..

Unknown said...

Спасибо man!!
I don´t know what I would do without this class...
have a nice Year!

Unknown said...

Спасибо Man!!!
save my week!
have a nice Year!

Anonymous said...

Thanks man!

Anonymous said...

Спасибище!

Anonymous said...

Nice fill someone in on and this fill someone in on helped me alot in my college assignement. Thank you for your information.

atasözleri said...

Ccontent is very old, writed in 2007.

IE8 or Google Popup Bloker catching it, can anyone help me?

Thanks again!

Anonymous said...

Works like a charm. Thanks !!

Anonymous said...

Nice and thanks!