Abrir una Ventana Principal para abrir otra ventana

16 views
Skip to first unread message

Eduardo Diaz

unread,
Sep 11, 2024, 12:06:48 AM9/11/24
to Apps Script en Español
Buena noches. estoy haciendo un proyecto que consiste en abrir una ventana principal, en ella debe tener un boton que al hacer click abre otra ventana. En esta segunda ventana tiene un boton que al hacer click abre una tercera ventana, luego el proceso sigue hasta completar seis ventanas. Este codigo me lo dio Chat GPT, pero no abre a partir de la tercera ventana. Aqui les dejo el codigo, necesito de su ayuda. Muchas gracias de antemano

function doGet() {
  return HtmlService.createHtmlOutputFromFile('Window1')
      .setTitle('Ventana 1');
}

function openWindow2() {
  return HtmlService.createHtmlOutputFromFile('Window2').getContent();
}

function openWindow3() {
  return HtmlService.createHtmlOutputFromFile('Window3').getContent();
}

function openWindow4() {
  return HtmlService.createHtmlOutputFromFile('Window4').getContent();
}

function openWindow5() {
  return HtmlService.createHtmlOutputFromFile('Window5').getContent();
}

function openWindow6() {
  return HtmlService.createHtmlOutputFromFile('Window6').getContent();
}

<!DOCTYPE html>
<html>
<head>
  <base target="_top">
</head>
<body>
  <h1>Ventana 1</h1>
  <p>Esta es la primera ventana.</p>
  <button onclick="openWindow2()">Abrir Ventana 2</button>

  <script>
    function openWindow2() {
      google.script.run.withSuccessHandler(function(htmlContent) {
        var newWindow = window.open("", "_blank", "width=400,height=300");
        newWindow.document.open();
        newWindow.document.write(htmlContent);
        newWindow.document.close();
      }).openWindow2();
    }
  </script>
</body>
</html>

<!DOCTYPE html>
<html>
<head>
  <base target="_top">
</head>
<body>
  <h1>Ventana 2</h1>
  <p>Esta es la segunda ventana.</p>
  <button onclick="openWindow3()">Abrir Ventana 3</button>

  <script>
    function openWindow3() {
      google.script.run.withSuccessHandler(function(htmlContent) {
        var newWindow = window.open("", "_blank", "width=400,height=300");
        newWindow.document.open();
        newWindow.document.write(htmlContent);
        newWindow.document.close();
      }).openWindow3();  // Aquí llama a la función del servidor
    }
  </script>
</body>
</html>

y asi sucesivamente hasta la ventana seis
<!DOCTYPE html>
<html>
<head>
  <base target="_top">
</head>
<body>
  <h1>Ventana 3</h1>
  <p>Esta es la tercera ventana.</p>
  <button onclick="openWindow4()">Abrir Ventana 4</button>

  <script>
    function openWindow4() {
      google.script.run.withSuccessHandler(function(htmlContent) {
        var newWindow = window.open("", "_blank", "width=400,height=300");
        newWindow.document.open();
        newWindow.document.write(htmlContent);
        newWindow.document.close();
      }).openWindow4();
    }
  </script>
</body>
</html>

Reply all
Reply to author
Forward
0 new messages