I recently built an AIR app using HTML, CSS and JavaScript. In the web version there is a button on the Capacity tab that opens a new window with the calculated results. After packaging this into an AIR application the app attempts to open the new window but fails.
I read about doing such here, but I am not exactly sure how to implement the code (which follows below).
I would appreciate some guidance to know where this code would go. If there is an "easier" way to accomplish the same results, I am all ears.
Thanks!
<?xml version="1.0" encoding="utf-8"?>
<mx:WindowedApplication xmlns:mx="http://www.adobe.com/2006/mxml" layout="absolute">
<mx:HTML id="htmlComp" width="100%" height="100%" location="http://www.rediff.com"complete="addEventListenersToLinks(event)" />
<mx:Scri开发者_运维技巧pt>
<![CDATA[
private function addEventListenersToLinks(e:Event):void
{
var dom:Object = e.currentTarget.domWindow.document;
var links:Object = dom.getElementsByTagName("a");
for(var i:Number = 0; i < links.length; i++)
{
if(links[i].target.toLowerCase() == "_blank" || links[i].target.toLowerCase() == "_new")
links[i].onclick = linkClickHandler;
}
}
private function linkClickHandler(o:Object):void
{
navigateToURL(new URLRequest(o.currentTarget.href),"blank");
}
]]>
</mx:Script>
</mx:WindowedApplication>
This was a lot easier than I thought. Basic JavaScript:
CapacityWindow = window.open(document.location, 'CapacityWindow', 'toolbar=1,scrollbars=1,menubar=1,width=800,height=950');
精彩评论