0

I have written a standalone google app script for a google web app. when I open a new window on the click of the submit button i get the following error.

userCodeAppPanel:23 Unsafe attempt to initiate navigation for frame with origin 'https://script.google.com' 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.

I have tried to add a dynamic anchor tag and then add a click event on the same . still it does not work.

I have created a dynamic anchor tag with the link and activated the click event .

 var templink= url+"?role="+role+"&sheetname="+sheets+"&page=Link2"; // 

var temp="window.open("+"'"+templink+"'"+",'popup','width=1000,height=1000','_top')"; 
var link = document.createElement('a'); 
link.id = 'linkURL'; 
link.setAttribute('target', '_top'); document.body.appendChild(link); link.setAttribute('onclick',temp); document.getElementById("linkURL").click(); 
Rubén
  • 34,714
  • 9
  • 70
  • 166
Shyamala R
  • 11
  • 1
  • Currently you have a client side javascript error somewhere around line 23 maybe. That's all I can tell you without additional information. Debugging webapps can be tough but the only way to learn is to do it. I'll be glad to help but I think your going to have to do the leg work. – Cooper Jun 16 '22 at 14:48
  • 2
    As the error says, you need a user to click something to start navigation. You cannot automatically navigate anywhere programmatically. – TheMaster Jun 16 '22 at 14:50
  • 1
    Please provide enough code so others can better understand or reproduce the problem. – Community Jun 16 '22 at 15:04
  • 1
    error resolved after automatic click event for anchor tag – Shyamala R Jun 21 '22 at 09:24
  • Duplicate of https://stackoverflow.com/q/69128777/1595451 – Rubén Jun 24 '22 at 22:45

0 Answers0