Google's JavaScript API makes use of the function document.write, thus is not usable in XHTML.
Do you know a workaround how to get the custom search working in XHTML? Or is there a working alternative?
Google's JavaScript API makes use of the function document.write, thus is not usable in XHTML.
Do you know a workaround how to get the custom search working in XHTML? Or is there a working alternative?
Copyright © 2021 Jogjafile Inc.
Are you actually serving your XHTML as XML (
application/xhtml+xml)? If not, you don't have to worry about it, yet.document.writewill still work intext/htmlmode though it is certainly poor practice in general.If you really are serving native XHTML... well, I suspect you may get more problems than just
document.write, as there are a fair few things that can trip scripting up when it's not expecting to be run in XHTML. But you can hack it the problem by sabotagingdocument.write.The simplest method would be something like:
however you would need more messing around if it tried to write
<script>tags (since setting them throughinnerHTMLdoesn't execute them; you would have to pick them out withgetElementsByTagNameand run each one manually), or partial bits of elements across different calls towrite(in which case you'd have to collect strings and glue them together when it's finished).