I have a multi-page Web App. I want after login, a user sees the list of his teammate and marks their attendance status. My issue is I can't show that in an iFrame rather than google script original one.
For instance, I wanted to iFrame it to my own web page. it is two days I can't overcome this issue, I read lots of posts in this regard and also tried another app from scratch, but no luck yet.
For clarification, I am redirecting the user inside the frame using render function. So as @theMaster mentioned it is not a multi-page Web App.
here is my doGet and Render functions:
function doGet(e){
// Logger.log(e);
Route.path("login",loadLogin);
Route.path("admin",loadAdmin);
Route.path("view",loadView);
Route.path("form",loadForm);
if (e.parameters.id){
LastID=e.parameters.id[0];
}
if (e.parameters.t){
curT=e.parameters.t[0];
}
if (Route[e.parameters.v]) {
return Route[e.parameters.v]();
} else {
return render('W-home');
}
}
function render(file, argObject){
var page = HtmlService.createTemplateFromFile(file);
if (argObject){
var keys = Object.keys(argObject);
keys.forEach(function (k){
page[k]=argObject[k];
});
}
var evalPage =page.evaluate();
// if (!xFrame){return evalPage;};
return evalPage.setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL);
}
I can go from home page to login page, but after that, even it doesn't let me go to google. In some cases also just returns a blank page inside the frame.
Here is my sample code for the client-side JavaScript.
function goToForm(EmpNo) {
var link = "<?!=ScriptApp.getService().getUrl()?>" + "?v=form&id=" + EmpNo[1] + "&t=" + EmpNo[2];
location.href = link;
// I tried different way to see if i can conqure this!
// if (clickBTN= 'a') {
// window.open(link, "_self");
// } if (clickBTN= 'b') {
// location.href=link;
// } if (clickBTN= 'c') {
// openNewURLInTheSameWindow(link);
// }
}
I also have two global variables xFrame
to set XframeOptionsMode to allowAll
or not and base
to switch base target on the HTM pages to "_top" or "_self".
Question&Answers:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…