google scripts/html 试图在页面中显示页面

首先我要展示我的代码,这是我正在运行的 html 代码:


<!DOCTYPE html>

<html>

    <head>

    <title>Elliots Site</title>

    <base target="_top">

    <?!= include('Gcss'); ?>

      <script type="text/javascript">

       

      </script>

    </head>

    <body>

    <div class="page">

      <iframe style="width: 100%; height: 100px; overflow: hidden;" src="http://google.com" width="100" height="100" scrolling="no">Iframes not supported</iframe>

      <h1 class="emoj">"😀"</h1>

     </div> 

        <?!= include('Gjavascript'); ?>

    </body>

</html>

这是我的 css 文件:


<style>

    /* CSS reset */

body,div,dl,dt,dd,ul,ol,li,h1,h2,h3,h4,h5,h6,pre,form,fieldset,input,textarea,p,blockquote,th,td { 

    margin:0;

    padding:0;

}

      html, body {

  margin: 0;

  padding: 0;

}


body {

  font-family: 'Roboto', sans-serif;

  font-weight: 100;

}


.page iframe {

vertical-align:center;

width=200%;

height=100%;

}

.page .emoj {

text-align:center;

color:auto;

vertical-align:center;

}

.page{

background-color:white;

align-items: center;

height:400px;

background-attachment: fixed;

background-repeat: no-repeat;

text-align:center;

}

<style>

我还有两个文件来运行代码和应用 css 文件,我很确定这不是问题所在。第一个是 gs 文件,它是 js 的一种形式,代码从 doGet 开始


function doGet() {

return HtmlService.createTemplateFromFile('gindex')

.evaluate();

}

function include(filename) {

  return HtmlService.createHtmlOutputFromFile(filename)

  .getContent();

}

另一个是html:


<!DOCTYPE html>

<script>

window.addEventListener('load', function() {

  console.log('Page is loaded');

});

</script>

好的,现在的问题。当前结果只是一个空白页,甚至没有打印文本。到目前为止,我还没有尝试过任何能取得很大成功的方法,到目前为止,我已经在 css 文件上工作以尝试修复它。我做过研究,但在谷歌脚本上找不到太多。代码的目标是在网站内部显示谷歌主页,我一直将其部署为网页。这是我的第一篇文章如果您有任何问题我可以回答或测试请告诉我


侃侃无极
浏览 100回答 1
1回答

慕勒3428872

你的代码看起来有点混乱,因为它是如何提供的,所以为了演示目的,我自己做了。如果您想将 google.com 第一页“嵌入”到您的网站,请使用 iframe 但不要使用 google.com,请尝试使用此链接 =>&nbsp;https://www.google.com/webhp?igu=1否则它会什么都不显示。PS 要预览代码,请使用全页模式。&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; .frame {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; height: 700px;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; width: 600px;&nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; .page {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; text-align: center;&nbsp; &nbsp; &nbsp; &nbsp; }&nbsp; &nbsp; &nbsp; &nbsp;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; body {&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; background-color: grey;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; height: 100vh;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; overflow: hidden;&nbsp; &nbsp; &nbsp; &nbsp; }<!DOCTYPE html><html><head>&nbsp; &nbsp; <meta charset="UTF-8">&nbsp; &nbsp; <meta name="viewport" content="width=device-width, initial-scale=1.0">&nbsp; &nbsp; <title>IRONIXX</title></head><body>&nbsp; &nbsp; <section class="page">&nbsp; &nbsp; &nbsp; &nbsp; <h1 class="emoj">"😀"</h1>&nbsp; &nbsp; &nbsp; &nbsp; <iframe class="frame" src="https://www.google.com/webhp?igu=1" frameborder="0"></iframe>&nbsp; &nbsp; </section></body></html>

不负相思意

我知道这不能直接解决您的空白页面情况,但如果您有兴趣在您的网站中嵌套另一个网站,也许您会对使用 iframe感兴趣?这是一个发电机。尝试打卡google.com,看看是否可以将其嵌入到您的站点中。
打开App,查看更多内容
随时随地看视频慕课网APP

相关分类

JavaScript