Javascripts not working under XHTML

Kerberos (2)

Usenet Archive
Joined
Dec 2, 2004
Messages
12
Reaction score
0
When I deliver a page as text/html, the javascripts work, but if delivered as application/xhtml+xml, the javascripts don't work:

function OpenBrWindow(theURL,winName,features, myWidth, myHeight, isCenter) { //v3.0 if(window.screen)if(isCenter)if(isCenter=="true"){ var myLeft = (screen.width-myWidth)/2; var myTop = (screen.height-myHeight)/2; features+=(features!='')?',':''; features+=',left='+myLeft+',top='+myTop; } window.open(theURL,winName,features+((features!='')?',':'')+'width='+myWidth+',height='+myHeight); }

function Glaydon {
var uservar = "vendas";
var servidor = "cpedobrasil";
var ext = ".com.br";
document.write("<a href=" + "mail" + "to:" + uservar + "@" + servidor+ ext + ">" + uservar + "@" + servidor + ext + "</a>"); }

I'm desperate. I include the javascripts this way:
<script type="text/javascript" src="javascript.js"></script> Is there a way to have them to work? I just saw that document.write; doesn't work under XHTML. Is there a way to have a similar feature ?
Thanks,
 

Richard Cornford

Usenet Archive
Joined
Aug 17, 2002
Messages
6,000
Reaction score
0
Kerberos said:
When I deliver a page as text/html, the javascripts
work, but if delivered
as application/xhtml+xml, the javascripts don't work:

HTML DOMs and XHTML DOMs are quite distinct creatures (both by specification and by implementation). If you write a script for an HTML DOM there is quite a good chance that it will not work correctly (if at all) with an XTHML DOM (and the other way around).

document.write("<a href=" + ...
<snip>

There are currently *no* XHTML DOM implementations that support document write.

In addition, when scripting XHTML you need to be aware of the use of namespaces and the case sensitivity of XHTML (as covered in the HTML level 2 DOM specification from the W3C).

Unfortunately there are people who present XHTML and then script it as if it was HTML, without mentioning the serious caveats about serving those (exclusively Appendix C XHTML 1.0) pages as text/html so that the receiving browser will put a lot of additional effort into interpreting the pages as tag-soup HTML (Thus creating the HTML DOM that the script is expecting). That is quite dishonest of them, and misleads others into believing that they can get away with scripting XHTML as if it was HTML.

In practice the vast majority of the people who understand the situation would recommend that currently, in any commercial context, HTML should be authored instead of XHTML whenever client-side scripting is to be used (and often even when scripting is not to be used).

Richard.
 

Arjun Ray

Usenet Archive
Joined
Jan 22, 2000
Messages
62
Reaction score
0
<snip>

There are currently *no* XHTML DOM implementations that support document write.

And I hope there never will be. The idea of *writing tags* (instead of adding/deleting/moving objects or modifying properties) is hideously brain-damaged. (And people who want it, or think they "need" it, are still in the coils of the tagsoup mindset.)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
548,042
Messages
3,104,224
Members
248,132
Latest member
henrywalsh

Latest Threads

Top