admin管理员组文章数量:1333487
Error: Unsafe attempt to initiate navigation for frame with origin '' from frame with URL ''. The frame attempting navigation of the top-level window is sandboxed with the 'allow-top-navigation-by-user-activation' flag, but has no user activation (aka gesture). See .
Code:
function ModelViewer(token) {
if (!token) {
console.log("No token found");
return;
}
// Fetch the URL dynamically
google.script.run.withSuccessHandler(function (appUrl) {
console.log("Fetched URL:", appUrl);
google.script.run.withSuccessHandler(function (isValid) {
if (isValid) {
console.log("isValid it is!")
console.log("Token", token);
const link = document.createElement('a');
link.href = `${appUrl}?page=Models&token=${token}`;
link.id = 'linkURL';
document.body.appendChild(link);
document.getElementById('linkURL').click();
} else {
console.log("isValid",isValid);
console.log("Token", token);
console.log("Invalid token. Redirecting to SignIn.");
showNotification("Session expired. Please sign in again.", "error");
}
}).validateToken(token);
}).getAppUrl(); // Call the server-side function to get the URL
}
Error: Unsafe attempt to initiate navigation for frame with origin 'https://script.google' from frame with URL 'https://n-x4qqieogl32dh7vitgxnysfogdq2h5ccinv5p6a-0lu-script.googleusercontent/userCodeAppPanel'. The frame attempting navigation of the top-level window is sandboxed with the 'allow-top-navigation-by-user-activation' flag, but has no user activation (aka gesture). See https://www.chromestatus/feature/5629582019395584.
Code:
function ModelViewer(token) {
if (!token) {
console.log("No token found");
return;
}
// Fetch the URL dynamically
google.script.run.withSuccessHandler(function (appUrl) {
console.log("Fetched URL:", appUrl);
google.script.run.withSuccessHandler(function (isValid) {
if (isValid) {
console.log("isValid it is!")
console.log("Token", token);
const link = document.createElement('a');
link.href = `${appUrl}?page=Models&token=${token}`;
link.id = 'linkURL';
document.body.appendChild(link);
document.getElementById('linkURL').click();
} else {
console.log("isValid",isValid);
console.log("Token", token);
console.log("Invalid token. Redirecting to SignIn.");
showNotification("Session expired. Please sign in again.", "error");
}
}).validateToken(token);
}).getAppUrl(); // Call the server-side function to get the URL
}
Share
Improve this question
edited Nov 21, 2024 at 7:45
TheMaster
50.9k7 gold badges70 silver badges99 bronze badges
asked Nov 20, 2024 at 17:57
DhruvDhruv
133 bronze badges
1
|
1 Answer
Reset to default 0As the sandbox name, allow-top-navigation-by-user-activation'
says, you can't navigate to another page without a user interaction. The link needs to clicked by the end user with the target attribute set to the top frame.
const link = document.createElement('a');
link.href = `${appUrl}?page=Models&token=${token}`;
link.id = 'linkURL';
link.target = '_top'
link.innerText = 'Signed in! Click Here to continue!'
document.body.appendChild(link); //No auto click possible
本文标签: google apps scriptUnable to navigate to the page after sign InStack Overflow
版权声明:本文标题:google apps script - Unable to navigate to the page after sign In - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1742339426a2456296.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
windows.open("enter-your-link")
– Gyul Commented Nov 21, 2024 at 21:16