问题描述
我正在尝试在html文档中编写内容.这是我的JavaScript代码:
I am try to write inside html document.this is my javascript code:
<script type="text/javascript">document.write("Hello World!")</script>
我正在使用chrome并出现以下错误:
I am working with chrome and get the following error:
我尝试了alert
方法,它起作用了.
I tried alert
method and it worked.
这是scala/lift中项目的一部分,如果有暗示的话,它也会使用jquery.我怀疑文档对象已重新定义.有没有办法知道/访问原始的?
this is part of a project in scala/lift that also uses jquery if that may hint something. I suspect document object is redefined. is there a way to know that / to access the original one?
推荐答案
我遇到了类似的问题,试图将google maps api嵌入到我的Lift应用程序中.该脚本还使用document.write加载外部库.Google Chrome控制台指出没有功能document.write.
I had a similar problem, trying to embed the google maps api in my lift application. The script also uses document.write to load external libraries.The Google Chrome console stated that there is no function document.write.
问题似乎是XHTML不允许document.write. ( http://www.w3.org/MarkUp/2004/xhtml-faq# docwrite )解决方案可能是更改文档的哑剧/类型,例如通过将以下行添加到Boot.scala
The problem seems to be that XHTML does not allow document.write. ( http://www.w3.org/MarkUp/2004/xhtml-faq#docwrite )A solution could be to change the mime/type of your documents, e.g. by adding the following line to your Boot.scala
LiftRules.useXhtmlMimeType = false
LiftRules.useXhtmlMimeType = false
更多解决方案在下面的链接中描述 http ://scala-programming-language.1934581.n4.nabble.com/Google-Maps-API-V2-amp-V3-Ajax-Loading-td1981862.html
More solutions are described in the link belowhttp://scala-programming-language.1934581.n4.nabble.com/Google-Maps-API-V2-amp-V3-Ajax-Loading-td1981862.html
这篇关于document.write在html中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!