简体   繁体   English

在谷歌应用脚本上的 html 代码中导入 html 文件

[英]Importing html file inside html code on google app script

I have made an html file called navBar.html我制作了一个名为 navBar.html 的 html 文件

    <nav id="navbar">
    <ul>
      <li class="dropdown" style= "background-color: #191970" >
        <?var url = getScriptUrl();?><a href='<?=url?>?page=Page' target="_top" id="Home" class="dropbtn">Home</a>
        <div class ="dropdown-content">
        </div>
      </li>
      <li class="dropdown"style= "background-color: #191970">
          <a href="https://script.google.com/macros/s/AKfycbyyYKI6fGf_LnRA8jPDa1QTJwUGqrG34lTDmHyugMHFZ4LYcWF4OBxjxa6BPtRyw-gj/exec" target="_top" id="Game" class="dropbtn">Games</a>
          <div class ="dropdown-content">
          </div>
      </li>
      <li class="dropdown" style= "background-color: #191970" >
        <a href="#"  class="dropbtn">Cipher</a>
        <div class ="dropdown-content">
          <?var url = getScriptUrl();?><a href='<?=url?>?page=Caesar_Cipher' target="_top" id="Caesar_Cipher" name="Caesar_Cipher"> Caesar_Cipher </a>
          <?var url = getScriptUrl();?><a href='<?=url?>?page=Simple_Substitution_Cipher' target="_top" id="Simple_Substitution_Cipher" name="Simple_Substitution_Cipher"> Simple_Substitution_Cipher </a>
          <?var url = getScriptUrl();?><a href='<?=url?>?page=Playfair_Cipher' target="_top" id="Playfair_Cipher" name="Playfair_Cipher"> Playfair_Cipher </a>
          <?var url = getScriptUrl();?><a href='<?=url?>?page=Vigenere_Cipher' target="_top" id="Vigenere_Cipher" name="Vigenere_Cipher"> Vigenere_Cipher </a>
          <?var url = getScriptUrl();?><a href='<?=url?>?page=One_Time_Pad' target="_top" id="One_Time_Pad" name="One_Time_Pad"> One_Time_Pad </a>
          <?var url = getScriptUrl();?><a href='<?=url?>?page=Transposition_Cipher' target="_top" id="Transposition_Cipher" name="Transposition_Cipher"> Transposition Cipher </a>
          <?var url = getScriptUrl();?><a href='<?=url?>?page=Feistel_Block_Cipher' target="_top" id="Feistel_Block_Cipher" name="Feistel_Block_Cipher"> Feistel_Block_Cipher </a>
        </div>
      </li>
    <li class="dropdown" style= "background-color: #191970" >
        <a href="#"  class="dropbtn">Encryptions</a>
        <div class ="dropdown-content">
          <?var url = getScriptUrl();?><a href='<?=url?>?page=DES' target="_top" id="DES" name="DES"> DES </a>
          <?var url = getScriptUrl();?><a href='<?=url?>?page=AES' target="_top" id="AES" name="AES"> AES </a>
          <?var url = getScriptUrl();?><a href='<?=url?>?page=RSA' target="_top" id="RSA" name="RSA"> RSA </a>
          <?var url = getScriptUrl();?><a href='<?=url?>?page=ElGamal_Cryptosystem' target="_top" id="ElGamal_Cryptosystem" name="ElGamal_Cryptosystem"> ElGamal_Cryptosystem </a>
          <?var url = getScriptUrl();?><a href='<?=url?>?page=Triple_DES' target="_top" id="Triple_DES" name="Triple_DES"> Triple_DES </a>
        </div>
      </li>
    </ul>
  </nav>

I am trying to reuse this code in several different pages by importing it.我试图通过导入在几个不同的页面中重用此代码。 For example, in my index.html file, instead of copying and pasting the navbar, I want to import it into the body.比如在我的 index.html 文件中,不是复制粘贴导航栏,而是想将其导入正文。 I tried using jquery load function, html5 import, and even w3.js and all were not able to import my html code. I tried using jquery load function, html5 import, and even w3.js and all were not able to import my html code. I am using an unbound script, with code.gs, navBar.html and index.html.我正在使用未绑定的脚本,其中包含 code.gs、navBar.html 和 index.html。 Any recommendations or ideas on how to proceed with reusing navbar.html inside index.html with google script web pages.关于如何在 index.html 中重用 navbar.html 和谷歌脚本 web 页面的任何建议或想法。

After evaluating your situation I came with a simple fix.在评估了您的情况后,我提出了一个简单的解决方法。 I strongly recommend you to implement templates .我强烈建议您实现模板 With them you can dynamic HTMLs with the minimal effort.有了它们,您可以轻松地动态 HTML。 Please follow the guide and its examples.请遵循指南及其示例。 Feel free to write back if you find any issue with it.如果您发现任何问题,请随时回信。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM