Javascripts not working under XHTML

Discussion in 'XML' started by Kerberos, Dec 13, 2004.

  1. Kerberos

    Kerberos Guest

    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,

    --

    Kerberos.

    http://www.opera.com
    http://www.freebsd.org
    http://www.osresources.com
    http://exodus.jabberstudio.org
    Kerberos, Dec 13, 2004
    #1
    1. Advertising

  2. Kerberos wrote:
    > 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).

    <snip>
    > 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.
    Richard Cornford, Dec 14, 2004
    #2
    1. Advertising

  3. Kerberos

    Arjun Ray Guest

    On Tue, 14 Dec 2004 01:12:41 +0000, Richard Cornford wrote:

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

    > <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.)
    Arjun Ray, Dec 16, 2004
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    7
    Views:
    876
  2. chronos3d
    Replies:
    9
    Views:
    771
    Andy Dingley
    Dec 5, 2006
  3. Usha2009
    Replies:
    0
    Views:
    1,127
    Usha2009
    Dec 20, 2009
  4. sdvoranchik
    Replies:
    1
    Views:
    133
    Thomas 'PointedEars' Lahn
    Jan 31, 2004
  5. Kerberos

    Javascripts not working under XHTML

    Kerberos, Dec 13, 2004, in forum: Javascript
    Replies:
    2
    Views:
    71
    Arjun Ray
    Dec 16, 2004
Loading...

Share This Page