By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,480 Members | 1,743 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,480 IT Pros & Developers. It's quick & easy.

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

P: n/a
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>Adiciona 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"},{"progid":"2","loc":"reqcomb","nome":"R equisi\u00e7\u00e3o
de
Combust\u00edvel"},{"progid":"3","loc":"admreqcomb ","nome":"Administra\u00e7\u00e3o
do Requisi\u00e7\u00e3o de Combust\u00edvel"}];

function init () {
admusuario_cadastra_modulo_init (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_cadastra_modulo_init()'
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

Sep 19 '06 #1
Share this Question
Share on Google+
8 Replies


P: n/a
VK

br*******@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)

Sep 19 '06 #2

P: n/a
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

Sep 19 '06 #3

P: n/a
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
Sep 19 '06 #4

P: n/a
br*******@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/>
Sep 19 '06 #5

P: n/a
VK

br*******@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.

Sep 19 '06 #6

P: n/a
VK

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.

Sep 19 '06 #7

P: n/a
Michael Winter <m.******@blueyonder.co.ukwrites:
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
Sep 20 '06 #8

P: n/a
Eric B. Bednarz wrote:
Michael Winter <m.******@blueyonder.co.ukwrites:
[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
Sep 20 '06 #9

This discussion thread is closed

Replies have been disabled for this discussion.