0

I want all my web app pages (Google app script )to be at same tab some thing like target = "_self"
but that did not work. when I'm am in the page index and I click the link it es work without problem and now I'm in index2 when I click at the buttom nothing happen only white empty page is there. someone can help me please! I will show you the code

\\code.gs

 function doGet(e) {
  if(e.parameters.v == "index2")
  return test2();

  else return test();
}

function test(){
  return HtmlService.createTemplateFromFile('Index').evaluate().setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL);
}


function test2(){
   return HtmlService.createTemplateFromFile('Index2').evaluate().setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL);
}

index.html 

<!DOCTYPE html>
<html>
  <head>

  <style>
  .iframe{
   display: none;
  }
  .fullScreen {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;

}

   </style>

         <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
         <script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>


  </head>
  <body>
  <button class="btn waves-effect waves-light" id="btn"> to Index 2     </button> 
<script>
 document.getElementById("btn").addEventListener("click", fireOff);

 function fireOff(){

  window.open(
    "<?= ScriptApp.getService().getUrl(); ?>?v=index2"
        ,"_self");             
 }


</script>
</body>
</html>

index2.html
<!DOCTYPE html>
<html>
  <head>

  <base target="_self">
         <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
         <script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/1.0.0/js/materialize.min.js"></script>

  </head>
  <body>
    <h1> Hi i am iFrame </h1>


 <button class="btn waves-effect waves-light" id="btn">to Index 1    </button> 




<script>
 document.getElementById("btn").addEventListener("click", fireOff);



 function fireOff(){
  window.open(
    "<?= ScriptApp.getService().getUrl(); ?>?v=inde2"
        ,"_self");             

 }



</script>
</body>


</html>



Marios
  • 26,333
  • 8
  • 32
  • 52
Hazem
  • 1
  • 1
  • Use `_top`..... – TheMaster Jun 04 '20 at 10:32
  • 1
    Does this answer your question? [Refreshing a page opened with window.location.replace or window.open(url,'\_self') takes me to previous window](https://stackoverflow.com/questions/60607091/refreshing-a-page-opened-with-window-location-replace-or-window-openurl-self) – TheMaster Jun 04 '20 at 10:34
  • @TheMaster but when i use _top all the page will be reloaded and i don't want that because the whole app is in iframe in a website – Hazem Jun 04 '20 at 10:39
  • 1
    Try https://stackoverflow.com/questions/56400233/ – TheMaster Jun 04 '20 at 10:43
  • i could not really understand how is that work in Sand box. – Hazem Jun 04 '20 at 12:15
  • can u help me with my code and show me how should it looks like please :) – Hazem Jun 04 '20 at 12:16
  • 2
    No. It'll take too much time. If you have a well defined specific problem implementing the solution, ask a new question for that specific problem. See [ask] and [mcve] – TheMaster Jun 04 '20 at 13:55
  • 1
    If you don't wish to reload the page then just use google.script.run.wiithSuccessHandler().functionname() and have the server return the html and stick in where ever you wish. Take look at this: https://stackoverflow.com/a/47417380/7215091 – Cooper Jun 04 '20 at 14:44

0 Answers0