Mixing inline with external scripts... not working...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • brasilino@yahoo.com

    Mixing inline with external scripts... not working...

    Hi Folks:

    I'm trying to make a function from a inline script, which is called by
    <body'onload' event, calling
    an function in a external script, with no success. I'm using XHTML.
    I've tried many ways....
    Here comes the snippet (without XML prolog and DOCTYPE declaration):

    <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="pt-br"
    lang="pt-br">
    <head>
    <title>Adicio na e Remove Usuários</title>
    <link href="/sispr/css/sispr.css" rel="stylesheet "
    type="text/css"/>
    <meta http-equiv="Content-Type" content="text/html;
    charset=UTF-8"/>
    <script type="text/javascript" src="/sispr/js/funcoes.js"/>
    <script type="text/javascript" src="/sispr/js/json.js"/>
    <script type="text/javascript" src="/sispr/js/admusuario.js"/>
    <script type="text/javascript">
    //<![CDATA[

    var sProgs = [{"progid":"1"," loc":"cademp"," nome":"Cadastro de
    Empresas"},{"pr ogid":"2","loc" :"reqcomb","nom e":"Requisi\u00 e7\u00e3o
    de
    Combust\u00edve l"},{"progid":" 3","loc":"admre qcomb","nome":" Administra\u00e 7\u00e3o
    do Requisi\u00e7\u 00e3o de Combust\u00edve l"}];

    function init () {
    admusuario_cada stra_modulo_ini t (sProgs);
    };

    //]]>
    </script>
    <!-- subst -->

    </head>
    <body onload="init(); ">

    My problem is tha the value of 'sProgs' is generated server side by a
    PHP JSON extension... it's an
    database table enconded in a array. 'admusuario_cad astra_modulo_in it()'
    function is in
    'admusuario.js' external script.
    Javascript console of Firefox 1.0.8 says: 'Error function init() not
    defined' :-(
    I'd like not using AJAX to get 'sProgs' values.....

    Any help? Am I messing things up?

    thanks a lot in advance
    Lucas Brasilino

  • VK

    #2
    Re: Mixing inline with external scripts... not working...


    brasilino@yahoo .com wrote:
    <script type="text/javascript" src="/sispr/js/funcoes.js"/>
    You are serving this page with Content-Type application/xml+xhtml,
    right?
    (asking before really going inside the code: to sort out the most
    obvious options)

    Comment

    • brasilino@yahoo.com

      #3
      Re: Mixing inline with external scripts... not working...

      Hi
      <script type="text/javascript" src="/sispr/js/funcoes.js"/>
      >
      You are serving this page with Content-Type application/xml+xhtml,
      right?
      (asking before really going inside the code: to sort out the most
      obvious options)
      Oops... no... I didn't see it on XHTML 1.0 specifications. ..
      But I tried to set this header and my Firefox is now trying to
      download the page... and I can't see where can I configure
      it to render the page, not to download.

      bests regards
      Lucas Brasilino

      Comment

      • brasilino@yahoo.com

        #4
        Re: Mixing inline with external scripts... not working...

        Hi:

        Let's suppose I've converted it to HTML 4.01. How should be the
        <scripttag ?

        regards
        Lucas Brasilino
        Hi
        >
        <script type="text/javascript" src="/sispr/js/funcoes.js"/>
        You are serving this page with Content-Type application/xml+xhtml,
        right?
        (asking before really going inside the code: to sort out the most
        obvious options)
        >
        Oops... no... I didn't see it on XHTML 1.0 specifications. ..
        But I tried to set this header and my Firefox is now trying to
        download the page... and I can't see where can I configure
        it to render the page, not to download.
        >
        bests regards
        Lucas Brasilino

        Comment

        • Michael Winter

          #5
          Re: Mixing inline with external scripts... not working...

          brasilino@yahoo .com wrote:

          [VK:]
          >You are serving this page with Content-Type application/xml+xhtml,
          >right?
          [snip]
          Oops... no... I didn't see it on XHTML 1.0 specifications. ..
          In the original publication, the MIME type hadn't been decided upon. The
          Recommendation has since been revised (see the updated section 5.1 [1]),
          and a separate Working Group Note has been published on the subject of
          XHTML media types[2]. In both cases, this information has been available
          since 2002.
          But I tried to set this header and my Firefox is now trying to
          download the page...
          That's because VK got the MIME type wrong. It should be
          application/xhtml+xml. However, even though Firefox, Opera, and others
          will render the document, MSIE won't as it doesn't feature a XML processor.

          Don't serve XHTML to user agents (at least not on the Web). Use HTML. If
          you really must use XHTML (and that's extremely doubtful), author to the
          guidelines in Appendix C.

          Mike


          [1] <http://www.w3.org/TR/xhtml1/#media>
          [2] <http://www.w3.org/TR/xhtml-media-types/>

          Comment

          • VK

            #6
            Re: Mixing inline with external scripts... not working...


            brasilino@yahoo .com wrote:
            Hi:
            >
            Let's suppose I've converted it to HTML 4.01. How should be the
            <scripttag ?
            With closing tag as it's supposed to be:


            <script type="text/javascript" src="script1.js "></script>
            <script type="text/javascript" src="script2.js "></script>
            <script type="text/javascript" src="script3.js "></script>
            <script type="text/javascript">
            // your inline script
            </script>

            See my posts in the recent discussion "Why people use this style of
            javascript declaration?" for more details.

            Comment

            • VK

              #7
              Re: Mixing inline with external scripts... not working...


              Michael Winter wrote:
              VK got the MIME type wrong. It should be
              application/xhtml+xml.
              Oops... A Freudistic typo ("XML plus some crap atop") while W3C wants
              "XHTML + some XML" :-)

              Sorry anyway.

              Comment

              • Eric B. Bednarz

                #8
                Re: Mixing inline with external scripts... not working...

                Michael Winter <m.winter@bluey onder.co.ukwrit es:
                That's because VK got the MIME type wrong.
                Surprise. :)
                [...] MSIE won't as it doesn't feature a XML
                processor.
                Surely you're joking, Mr. Winter!

                <!DOCTYPE foo [
                <!ENTITY bar 'bar'>
                ]>
                <foo>&bar;</foo>

                Works for me since IE 5.01 (served properly).


                --
                ||| hexadecimal EBB
                o-o decimal 3771
                --oOo--( )--oOo-- octal 7273
                205 goodbye binary 111010111011

                Comment

                • Michael Winter

                  #9
                  Re: Mixing inline with external scripts... not working...

                  Eric B. Bednarz wrote:
                  Michael Winter <m.winter@bluey onder.co.ukwrit es:
                  [snip]
                  >[...] MSIE won't as it doesn't feature a XML processor.
                  >
                  Surely you're joking, Mr. Winter!
                  I wasn't, but I wish I had been. I have no idea what possessed me to
                  write that.
                  <!DOCTYPE foo [
                  <!ENTITY bar 'bar'>
                  ]>
                  <foo>&bar;</foo>
                  >
                  Works for me since IE 5.01 (served properly).
                  The application/xhtml+xml media type will not cause IE to invoke MSXML
                  to process a document, and though application/xml will, IE fails to
                  recognise or understand XHTML.

                  Mike

                  Comment

                  Working...