Hi! Thanks for visiting my blog. If you've received any value from my content would you mind supporting my new startup by downloading our browser add-on? It's called PriceBlink and makes online shopping a breeze. You can watch it in action here and download it for Chrome, Firefox, IE, or Safari by going to PriceBlink.com. Thank you and I hope you enjoy!

Flex and JavaScript Popups

Jul 30

I was posed with a question the other day about how to keep JavaScript in-line without hosting the mxml file within a container page (ie JSP, HTML, CF, etc). Flex handles in-line JavaScript popups very similar to Flash. If you’ve tried to make a call to:

getURL(“javascript:window.open(‘http://www.google.com’, ‘win’, ‘width=600, height=600′);”);

in Flash or Flex you’ll note the inherent problem with the new window being opened but also the child window (the one with the Flash movie) has been redirected a page that reads [object Window]. The Flash player actually redirects you to the URL instead of launching the new window and returning.

This describes the exact problem I was questioned about the other day. You can peak at the problem and the solution in an example below along with the code that drives it:

The key is to use the void(0) statement, which tells the browser to stop what it’s doing. The popup is launched and the browser is halted. Kind of a nuisance but it’s a little bit of code for what you gain from it.