AS3 - navigateToURL问题

时间:2014-01-30 14:37:26

标签: actionscript-3 flash

我的代码如下:

    botton_1.addEventListener(MouseEvent.MOUSE_UP, onClick);
function onClick(e:MouseEvent):void {
    var url:String = "http://www.xxxxxxxxxx.com/signInDetail";
    var request:URLRequest = new URLRequest(url);
    request.method = URLRequestMethod.POST;
    var variables:URLVariables = new URLVariables();
    variables.query = ta.text;
    variables.packageId = 1;
    variables.update = "askADoctorSaveQuery";
    variables.task = "CHAT_PRE_ACTIONS_WITHOUT_PACKAGEID";
    variables.query = ta.text;
    request.data = variables;
    var loader:URLLoader = new URLLoader();
    loader.addEventListener(Event.COMPLETE,compleHandler);
    loader.load(request);
}

function compleHandler(event:Event):void {
    var click_url2:String = "http://www.xxxxxxxx.com/ask-doctor-online";
    var request2:URLRequest = new URLRequest(click_url2);
    navigateToURL(request2, "_blank");

}

加载第一个请求并调用compleHandler后,navigateToURL方法会在弹出窗口中打开URL而不是新选项卡。我不确定是什么问题。

请帮忙......

2 个答案:

答案 0 :(得分:1)

替换此行。这会将其加载到一个新窗口中。

 navigateToURL(request2, "_blank");

您还有两个选择:
在父框架中:

navigateToURL(request2, "_parent");

替换当前页面:

navigateToURL(request2, "_self");

修改

重新检查后,我相信在新标签页中打开一个窗口是浏览器的用户首选项。开发人员似乎无法控制这一点。例如在IE 8中:

http://www.computershopper.com/feature/50-windows-7-tips-tweaks-and-secrets/open-a-link-in-a-new-tab-in-internet-explorer-8

答案 1 :(得分:-1)

navigateToURL(request2,“_ self”);