简体   繁体   English

我的基本w3.includeHTML()在PC服务器上执行的基本测试中不包含任何内容

[英]my basic w3.includeHTML() includes nothing in a basic test executed on my PC server

In debug, the include created about 30 temporary file named VMnnnn where n is an integer. 在调试中,include创建了约30个名为VMnnnn的临时文件,其中n是整数。 Each file contains the single letter "z". 每个文件包含单个字母“ z”。 None of the text to be included is there. 没有要包含的文本。

I created an html include file that has only text within paragraphs, ie 我创建了一个HTML包含文件,该文件的段落中只有文字,即

some text 一些文字

I invoke area without error. 我调用区域没有错误。 I traced the w3 invocations. 我跟踪了w3调用。

I am using Visual Studio Code, MAMP server, and executing debug as Launch Chrome. 我正在使用Visual Studio Code,MAMP服务器,并作为启动Chrome执行调试。 I tried Live Server, but read the w3.js should be tested when running in a server. 我尝试使用Live Server,但在服务器上运行时应阅读w3.js。

 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1"> <script src="https://www.w3schools.com/lib/w3.js"></script> <script src="../js/testHtmlInclude.js"></script> </head> <body class="container"> <img src = "../notables/notable1.jpg" style = "width:200px; height:300px;" > <h1>Nipper, K9</h1> <p>Lorem ipsum dolor sit amet consectetur adipisicing elit. Illo similique quisquam nostrum, omnis itaque aspernatur explicabo dolor minima officiis sequi.</p> <div w3-include-html="../notables/notable1.html"></div> </body> </html> testHtmlInclude.js: w3.includeHTML(); notable1.html: <p><b>Lorem ipsum</b> Dolor sit Amet consectetur adipisicing elit. Ipsum recusandae unde a quas omnis ex vitae nobis quae, laudantium saepe! Lorem ipsum dolor sit, amet consectetur adipisicing elit. Voluptate explicabo minima libero, omnis fugit exercitationem quae sit asperiores veniam iure quisquam delectus velit odit unde laudantium assumenda! </p> 

I expect the html code in the include file to be included. 我希望包含文件中的html代码被包含在内。 Nothing was. 没事

I realized I have to invoke the w3.includeHTML() function at the point in the code where I want the copied HTML placed. 我意识到我必须在代码中要放置复制的HTML的位置调用w3.includeHTML()函数。 I had defined the function in the but didn't invoke it (very embarrassing). 我已经在中定义了该函数,但没有调用它(非常尴尬)。 This is what i should have done: 这是我应该做的:

<body>
<div w3.include.html="path & filename"></div>
<script> w3includeHTML();</script>
</body>

I hope this helps other neophytes! 我希望这对其他新手有帮助!

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

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