Sunday, April 17, 2011

link to page in new tab/window

Everybody hates popups and annoying ads. They usually cover site and try to open new site. So there are ad blockers, etc. But sometimes there's need for creating "polite" site that really needs to open new one.

I found this solution somewhere. Please use it for non-offensive cases.

To open new site (e.g. click n button in flash) we have to call javascript on site so it will create form and submit it on the fly.

ExternalInterface.call('(function (){var f = document.createElement("form");document.body.appendChild(f);f.style.display="none";f.setAttribute("target","_blank");f.setAttribute("method","POST");f.setAttribute("action","'+url+'");f.submit(); })()');


IMPORTANT!
The whole code from above must be in one line.
There's url variable inside. Put there your url that is need to be open.

No comments:

Post a Comment