AIR HTMLLoader window.open 不起作用
AIR HTMLLoader window.open is not working
我有一个用Flex开发的Web项目,我必须使用AIR独立工作。
我创建了Air项目并使用flash.html.HTMLLoader加载了Web应用程序。内容加载正常且正常工作。
很少有按钮可以使用javascript函数window.open打开不同的链接。
链接未打开。javascript函数是使用外部接口调用的,我在显示的函数中放置了警报。
该函数包含简单的窗口。
window.open("http://www.google.co.in","Google");
我尝试了提到的几种解决方案,但没有一个有效。
http://digitaldumptruck.jotabout.com/?p=672
http://soenkerohde.com/2008/09/air-html-with-_blank-links/
http://cookbooks.adobe.com/index.cfm?event=showdetails&postId=9243
我什至尝试使用window.open方法在HTMLLoader组件中加载一个简单的页面,但它仍然不起作用。在按钮上单击,只有警报起作用,但窗口打开没有打开链接。
<html>
<head>
<title>Test</title>
<body scroll="no">
<input type="button" value="Click" onClick="window.open('http://www.google.co.in');">
</body>
</html>
有人可以帮我吗
这是一个激进的建议,可能会也可能不起作用,但我认为值得一试。
重写window.open
方法本身
和以前一样,等到Event.COMPLETE
被触发,然后从那里拿走它:
var html:HTMLLoader = new HTMLLoader();
var urlReq:URLRequest = new URLRequest("whatever.html");
var oldWindowOpen:Object; // save it, just in case
html.load(urlReq);
html.addEventListener(Event.COMPLETE,
function (event:Event):void {
oldWindowOpen = html.window.open;
html.window.open = asWindowOpen;
});
function asWindowOpen(href:String, name:String="_blank", specs:Object=null, replace:Object=null):void {
var urlReq = new air.URLRequest(href);
air.navigateToURL(urlReq);
}
您可能应该填写一些函数来处理 W3Schools 参考 for Window open() 方法中指定的其他输入。 为了安全起见,您可能必须(或想要)将所有参数类型更改为Object
,因为与外部接互不同,JavaScript-ActionScript 类型不会在 AIR-WebKit 交换中自动进行类型转换。
AIR Webkit 环境对 window.open
方法的支持非常严格。 请参阅 Adobe 文档,了解调用 JavaScript window.open() 方法的限制。
处理此问题的最简单方法是让系统的默认浏览器打开链接。Adobe记录了这个问题,并展示了如何从AIR中弹出打开的网址:
var url = "http://www.adobe.com";
var urlReq = new air.URLRequest(url);
air.navigateToURL(urlReq);
概括这一点:
function openExternalLink(href:String):void {
var urlReq = new air.URLRequest(href);
air.navigateToURL(urlReq);
}
一种选择:假设你在页面上运行jQuery,你可以让所有链接在外部打开,如下所示:
var html:HTMLLoader = new HTMLLoader();
var urlReq:URLRequest = new URLRequest("whatever.html");
html.load(urlReq);
html.addEventListener(Event.COMPLETE,
function completeHandler(event:Event):void {
html.window.jQuery('a').click(clickHandler);
});
function clickHandler( e:Object ):void {
if (e.target && e.target.href) {
openExternalLink(e.target.href);
}
e.preventDefault();
}
有关在 ActionScript 中处理 DOM 事件的更多信息,请参阅相关的 Adobe 文档。
这些都没有经过测试,但希望它能给出一个粗略的轮廓。
否则,如果你想做一些花哨的事情,比如弹出带有HTMLLoader框架的AIR窗口,我确实找到了一篇博客文章讨论这个问题:在AIR的HTML加载器中打开链接
- Windows.Open 在 window.Location 工作时不起作用
- window.open(url).print()在Safari中不起作用
- Javascript window.open()toolbar=no不起作用
- window.open()在使用phone gap的iOS应用程序上不起作用
- window.open在chrome中不起作用
- js window.open and print 在 google chrome 中不起作用
- AIR HTMLLoader window.open 不起作用
- Window.open() 在 Multiple if 条件中不起作用
- Window.open 在包含确认对话框的 if 条件中不起作用
- Javascript window.open on link 在 PHP 中不起作用
- window.open 在 IE8 中不起作用
- jQuery Mobile $(“#popup”).popup(“open”);转换页面后不起作用
- window.open() 在 IE11 中不起作用
- window.open()在ajax中不起作用
- Javascript onclick window.open不起作用
- window.open()在JSP中传递变量时不起作用
- window.open在IE10中不起作用
- Document.Open()不起作用
- Javascript Onclick window.open Popup在Firefox和Safari中不起作用
- win1=不同函数中的window.open和win1.close()不起作用