Javascript 动态html被调用到主html中-防止过度扶正document.write
我正在尝试将footer.html调用到main.html中。看起来document.write正在覆盖footer.html。如何在my main.html中显示Javascript 动态html被调用到主html中-防止过度扶正document.write,javascript,jquery,html,css,Javascript,Jquery,Html,Css,我正在尝试将footer.html调用到main.html中。看起来document.write正在覆盖footer.html。如何在my main.html中显示Date().getFullYear() main.html(主页): $(“#footer”).load(“footer.html”); footer.html(外部文件): ©;编写公司文档(新日期().getFullYear()) 看看这把小提琴: 您将注意到不需要jquery。您所需要的只是html: <d
Date().getFullYear()
main.html(主页):
$(“#footer”).load(“footer.html”);
footer.html(外部文件):
©;编写公司文档(新日期().getFullYear())
看看这把小提琴:
您将注意到不需要jquery。您所需要的只是html:
<div><span style="color:#444;">© Comp <script>document.write(new Date().getFullYear())</script></span></div>
©;编写公司文档(新日期().getFullYear())
函数的作用是:从服务器加载您不需要的数据,因此您可以将其删除。HTML单独与内联脚本应该足以获得您想要的内容。
文档。write
覆盖您现有的HTML。尝试将appendChild
与createTextNode
一起使用(将id添加到span标记中):
您遇到了什么问题???在my MAIN.HTML中,没有显示单词
©;Comp
。它只显示2014
文档。write覆盖副本;Comp,不要使用它。代码>有效。但是当我试图从邮件html页面调用它时,它只显示2014
@C-link Nepal:对不起,我不理解你的问题。谢谢,但我需要加载一个包含版权日期的外部html页面。
<div><span style="color:#444;">© Comp <script>document.write(new Date().getFullYear())</script></span></div>
<div><span style="color:#444;">© Comp <script>document.write(new Date().getFullYear())</script></span></div>
document.getElementById('copyright')
.appendChild( document.createTextNode(new Date().getFullYear()) );