1

I want to open a modal pop up in Google sheets

I have in code.gs:

function onOpen() {
SpreadsheetApp.getUi()
  .createMenu('Custom Menu')
  .addItem('Open Dialog Box', 'openDialog')
  .addToUi();
}

function openDialog() {
  var html = HtmlService.createHtmlOutputFromFile('index');

  SpreadsheetApp.getUi()
    .showModalDialog(html, 'Correct Postcode Errors');
}

In index.html

<!DOCTYPE HTML>
<HTML>
<body>

<iframe src="https://www.w3schools.com" title="W3Schools Free Online Web Tutorials"></iframe>

</body>
</html>

I get the popup but the Iframe does not connect

How to get the Iframe to connect?

Here is a Google sheet with the above code https://docs.google.com/spreadsheets/d/1LHiTZB225jFnOdzflUkm0ZSO6Wy_XQ_0OJ9WwAk46dA/edit?usp=sharing

Thanks

Marios
  • 26,333
  • 8
  • 32
  • 52
xyz333
  • 679
  • 6
  • 14
  • Maybe w3schools.com prevents you from doing that. Talk to them about it. – Cooper Jun 09 '20 at 19:20
  • Does your comment imply that it should work, but is not due to that particular URL? because I tried `https://www.google.com/` as well and that does not work either – xyz333 Jun 09 '20 at 19:25
  • Read my answer. – Cooper Jun 09 '20 at 19:25
  • I did and it tells me nothing. Read my answer to your comment – xyz333 Jun 09 '20 at 19:30
  • 2
    It tells what the is they refused to connect because they don't want you to iframe their website. I wouldn't either. – Cooper Jun 09 '20 at 19:36
  • 2
    @xyz333 Sites can prevent them from being shown in a iframe. Google and w3schools both have reasons to prevent/protect their sites from being iframed. There might be alternatives. Google forms would not let you iframe it directly, but it provides a specific iframe url for you to frame it – TheMaster Jun 09 '20 at 19:37
  • See https://stackoverflow.com/a/55127605 – TheMaster Jun 09 '20 at 19:42
  • I see, thank you both. If a site allows Iframes should the code above work? – xyz333 Jun 09 '20 at 20:37
  • Ok, I answered my own question. I does work – xyz333 Jun 09 '20 at 20:41

1 Answers1

2

www.w3schools.com refused to connect.

It tells that they refused to connect because they don't want you to iframe their website.

enter image description here

TheMaster
  • 45,448
  • 6
  • 62
  • 85
Cooper
  • 59,616
  • 6
  • 23
  • 54