在我的 Flex 页面中,我有一个导航到不同网页的链接,我想控制该子网页的大小。为了调整大小,我在我的 ActionScript 中使用 JavaScript 命令。这是动作脚本代码:
private function openLinkEvent():void{
var baseUrl:String ="https://localhost:8080/someWebsite?customerName="customer.custName;
var jscommand:String ="window.open(baseUrl,'win','height=280,width=500,toolbar=no,scrollbars=no,resizable=no');";
var url:URLRequest = new URLRequest("javascript:" + jscommand + " void(0);");
navigateToURL(url, "_self");
}
我在这段代码中有两个问题:
如果我按照上述方式进行操作,新窗口不会打开,Flex 页面会显示错误“baseUrl is undefined”。为什么我不能为我的 url 传递变量,而不是直接在 window.open 方法中传递 url?
如果我在 window.open 中直接传递我的 baseURL("https://localhost:8080/someWebsite?customerName="customer.custName;) 的值,它会将 customerName 的值作为 customer.custName 而它应该采用真实的保存在会话中的客户的价值。
澄清一下,当我以下列方式传递 baseUrl 时,我的应用程序运行良好。
navigateToURL(new URLRequest(baseUrl))
但是如果我想重新调整浏览器窗口的大小,上面的命令是不够的。这就是我使用与 ActionScript 集成的 JS 命令的原因。