script.googleusercontent.com refused to connect webapp href link not working

Viewed 332

The error I got in Google Chrome is following when clicked on the linked element.

n-f22j6yycycwkqttwlgfk5eezyixnbwfyfih4bba-0lu-script.googleusercontent.com refused to connect.

Html element is this ->

   <a href="" onclick="location.href = this.href+url+'?page=form2';return false;"> <img style="margin-right: 16px;" id="img1" height="200px" class="img-rounded" width="47%" src="https://drive.google.com/uc?export=view&id=16RE0CGxrEsXB9bBFj_Nq5jwTb5c8IMgU" alt="Image1"></a>

Note, "this.href" part has value empty. while url is variable stored the webApp Url.

Anyone has witnessed this problem and found how to fix it? It will save my day. Thank you.

1 Answers

The problem arises from using location.href in Apps Script

Use instead window.top.location.

<a href="" onclick="window.top.location = 'https://stackoverflow.com/';return false;"> <img style="margin-right: 16px;" id="img1" height="200px" class="img-rounded" width="47%" src="https://drive.google.com/uc?export=view&id=XXXXXXXXX" alt="Image1"></a>

works for me.

Related