Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
178
rated 0 times [  182] [ 4]  / answers: 1 / hits: 22902  / 13 Years ago, tue, september 27, 2011, 12:00:00

I am try to write inside html document.
this is my javascript code:



<script type=text/javascript>document.write(Hello World!)</script>


I am working with chrome and get the following error:




Uncaught TypeError: Object # has no method 'write'




I tried alert method and it worked.



EDIT: 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?


More From » jquery

 Answers
30

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.



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



More solutions are described in the link below
http://scala-programming-language.1934581.n4.nabble.com/Google-Maps-API-V2-amp-V3-Ajax-Loading-td1981862.html


[#89887] Monday, September 26, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
parker

Total Points: 259
Total Questions: 109
Total Answers: 97

Location: Zambia
Member since Thu, Jun 25, 2020
4 Years ago
;