Adobe air air.navigateToURL bug with internet explorer
I have a really bizarre problem with my adobe air app. I have a method which launches a local HTML file and passes some querystring items to it.
Here is the code:
function printWin(def) {
def = encodeURI(def);
var req = new window.runtime.flash.net.URLRequest('print.html');
req.method = 'GET';
var urlvars = new window.runtime.flash.net.URLVariables("d="+def);
req.data = urlvars;
air.navigateToURL(req);
return false;
}
The problem is, if this code is run when internet explorer is fully closed, it is fine and will create a URL like this:
file:///C:/Program%20Files%20(x86)/Gastrointestinal%20Tumors%20Dictionar/print.html?d=ABC
However, if internet explorer is already running and the code is run, this is the URL that is created:
C:\Program Files (x86)\Gastrointestinal Tumors 开发者_开发技巧 Dictionary\print.html
I am at a loss as to why this is but unfortunately I need to try and fix this urgently. Does anyone have any ideas?
Can you try building out the full URL instead of using the relative "print.html"?
Try this:
var url:String = File.applicationDirectory.url.substring(0, File.applicationDirectory.url.lastIndexOf("/") + 1) + "print.html";
var req = new window.runtime.flash.net.URLRequest(url);
...
That should get you the full file:///-style URL every time. The substring method attempts to hack off the current file so that you end up in the current directory, leaving you with the same ability to do a relative path, except that it's now fully qualified to your app root.
精彩评论