NULL
NULL

Reputation: 43

How to open a given Url?

I am using Google Apps Script with Google Drive, and I am a very beginner in this matter. Now, I would like to open a given Url in the same window. In standard JavaScript, there would be the 'open' method:

var windowObjectReference = window.open(strUrl, strWindowName[, strWindowFeatures]);

Probably, HtmlService would be the best solution with Google Apps Script. The following code should open the Google-site in the same window:

function doGet() {
     return HtmlService.createHtmlOutput(
     "<form action='http://www.google.com' method='get' id='foo'></form>" + 
     "<script>document.getElementById('foo').submit();</script>");
}

I opened Google Drive and created a new script. I typed in the above content in the editor of Google Docs Script. But when I am running this function from there, nothing at all will happen. Why so? Could you correct me? And what would be the code for opening Google in a new window?

Upvotes: 3

Views: 6373

Answers (1)

Arun Nagarajan
Arun Nagarajan

Reputation: 5645

Per the Release Notes for Oct 26, 2012 - you can no longer auto open a new window without user interaction.

The simplest way to open a new window to show an HTML like this -

<a href='http://www.google.com' target='_blank'>Open in new window</a>

Upvotes: 2

Related Questions