2

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

Arun Nagarajan said on this post https://stackoverflow.com/posts/13272748/edit

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

I want to open a Link in my google document (no spreadsheet)
directely by menu or by function !!

How to arrive with my script ?

  function onOpen() {
      // Add a menu with some items, some separators, and a sub-menu.
          DocumentApp.getUi().createMenu('OAR')

          .addItem('MAJ  Date + OAR', 'test')
          .addItem('MAJ  Date  Auto', 'testdate')
         ***.addItem('Accès Direct URL', 'href=/d/1udvLSpaZNgalg6NId JMJvkkw3i9oCaEKa-A_CAC79CYkvsZKD545dyZN/edit?')***

           .addToUi();
    }
Rubén
  • 34,714
  • 9
  • 70
  • 166
Lolowr
  • 81
  • 1
  • 3
  • 9

3 Answers3

-1

If you want to open a new page , use the class Anchor in Google App Script.

https://developers.google.com/apps-script/reference/ui/anchor?hl=fr

Hann
  • 727
  • 3
  • 11
  • 22
  • 2
    This method is deprecated in 2014 .https://developers.google.com/apps-script/reference/ui/anchor?hl=fr – Lolowr Mar 16 '15 at 11:18
-1

Looks like google scripts can't (don't allow us to) open links.
However you can show a dialog instructing the user..

since the UiApp is depreciated you can only use HtmlService to create HtmlOutput object then pass it to the UI

var content= 'You must go <a href="your_link">Here</a>';  //html as string
var html = HtmlService.createHtmlOutput(content);  //the output is the HtmlOutput
DocumentApp.getUi().showModalDialog(html, 'your_title');

or use DocumentApp.getUi().showModelessDialog(..., ...) if you don't want to prevent interaction with the document

and this will show the dialog with the wanted link

Check out this question Google Apps Script to open a URL

Community
  • 1
  • 1
Amr Saber
  • 988
  • 10
  • 26
-4

I think this will help you, with only JS. In parameter you can put the url you want as a string.

window.open(url);
Liam
  • 27,717
  • 28
  • 128
  • 190
El Morfix
  • 97
  • 1
  • I put this but don't work .function onOpen() { // Add a menu with some items, some separators, and a sub-menu. DocumentApp.getUi().createMenu('OAR').addItem('Appel Ro Paramedical', 'openropara') .addToUi(); } function oninstall() { onOpen() } function openropara() { window.open('https://docs.google.com/document/d/1omBMnoX4_Yf_5ooUxIFlZGYbx5PdlGqpwHIaezBnZnw/edit'); } – Lolowr Jun 25 '14 at 14:07
  • 1
    Because the answer is incorrect. Does not apply to apps script – Zig Mandel Jun 25 '14 at 14:50
  • My question is well posted in Google App Script.Perhaps not well formuled ..... how to do for this please ? – Lolowr Jun 25 '14 at 18:11