我们创建一个 iFrame 像
var iframe = dojo.io.iframe.create(generatedRequestId);
我们想插入一个额外的 javascript 函数,比如
函数 printThis() { window.print(); }
在 iFrame 中,以便在父窗口中我们可以从一些代码中调用 printThis() 函数,例如
_setPrintExportCookieInterval: function(/**String*/requestId, /**function*/closePopup, /**String*/exportTypeId) {
//have the interval autoexpire after some amount of seconds
var count = 0;
var intervalMs = 2000;
var intervalId = self.setInterval(function() {
var reportCookie = dojo.cookie(requestId);
if(reportCookie || count > 300000) { //5 mins
//if there's a status failure, don't close the window
if(reportCookie == "success") {
//console.debug(exportTypeId);
if(exportTypeId == PRINT) {
var iframe = dojo.byId(requestId);
iframe.printThis();
}
closePopup();
} else {
console.debug("print/export request returned with nonstandard status " + reportCookie);
}
window.clearInterval(intervalId);
//delete the cookie
dojo.cookie(requestId, null, {path: "/", expires: -1});
//destroy the iframe
//dojo.destroy(dojo.byId(requestId));
};
count+=intervalMs;
}, intervalMs);
return intervalId;
},
-这可能吗?我知道 dojo.io.iframe.create(generatedRequestId) 需要第二个参数,它将是 onLoad 执行的代码 - 但不一定是可以在 iframe 加载后调用的函数?
感谢您的任何建议。