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

SCRIPT tag

P: n/a
I'm having some trouble with my script tag. I'm trying to include a
piece of PHP text via the script tag by doing so:

<script src="http://pinata.no-ip.org/~altmarvel/Scripts.php"></script>

This produces nothing, but I don't know why. I've even gone so far as
to make it as simple as putting a simple HTML string inside
Scripts.php, which it refuses to print out. Yet, this refuses to print
anything out.

I've gotten some sample code from some 80s toy site, and the string
they use which works is:

<script src="http://www.seibertron.com/news/include_news.php"></script>

I have no clue what the difference between these two strings is, and
it's infuriating. Does anybody know? Is there a PHP switch or
something?
Jul 20 '05 #1
Share this Question
Share on Google+
14 Replies


P: n/a
li***************@yahoo.com (Liam Gibbs) wrote:
I'm having some trouble with my script tag. I'm trying to include a
piece of PHP text via the script tag by doing so:

<script src="http://pinata.no-ip.org/~altmarvel/Scripts.php"></script>

This produces nothing, but I don't know why.
Browsers don't ordinarily know how to execute PHP. Even if they did,
you would have to *tell* them that the script is going to be PHP by
using the SCRIPT tag's TYPE attribute. If you're using a browser that
doesn't disqualify the SCRIPT tag altogether for omitting the required
TYPE attribute, it expects Javascript when no type is given
explicitly.
I've even gone so far as
to make it as simple as putting a simple HTML string inside
Scripts.php, which it refuses to print out. Yet, this refuses to print
anything out.

I've gotten some sample code from some 80s toy site, and the string
they use which works is:

<script src="http://www.seibertron.com/news/include_news.php"></script>


What site? URL?
--
Harlan Messinger
Remove the first dot from my e-mail address.
Veuillez ôter le premier point de mon adresse de courriel.
Jul 20 '05 #2

P: n/a
Liam Gibbs wrote:
I'm having some trouble with my script tag. I'm trying to include a
piece of PHP text via the script tag by doing so:

<script src="http://pinata.no-ip.org/~altmarvel/Scripts.php"></script>
PHP is a server-side language interpreter.
I suppose you could try giving a "type" value, something like
type="text/php".

I have no clue what the difference between these two strings is, and
it's infuriating. Does anybody know? Is there a PHP switch or
something?

Do you know what PHP is?

--
jmm dash list at sohnen-moe dot com
(Remove .TRSPAMTR for email)
Jul 20 '05 #3

P: n/a
Liam Gibbs wrote:
I'm having some trouble with my script tag. I'm trying to include a
piece of PHP text via the script tag by doing so:

<script src="http://pinata.no-ip.org/~altmarvel/Scripts.php"></script>


You appear not to know what PHP is.

http://www.php.net/tut.php
http://www.php.net/manual/en/

--
Mark.
Jul 20 '05 #4

P: n/a
Liam Gibbs wrote:
<snip>
<script
src="http://pinata.no-ip.org/~altmarvel/Scripts.php"></script> <snip> <script
src="http://www.seibertron.com/news/include_news.php"></script>


If you enter:-

view-source:http://pinata.no-ip.org/~altmarvel/Scripts.php

- and:-

view-source:http://www.seibertron.com/news/include_news.php

- into the location/address bar of a web browser to view the material
actually being sent to the browser you will find that the first is
returning a fragment of HTML, while the second is returning valid
javascript source code.

The second works because the browser's javascript interpreter is able to
understand and execute javascript source code, while its interpretation
of an HTML fragment will be as a series of javascript syntax errors, and
it will terminate its attempt to execute the script at the first it
encounters.

Richard.
Jul 20 '05 #5

P: n/a
"Liam Gibbs" <li***************@yahoo.com> a écrit dans le message de
news:62**************************@posting.google.c om
I'm having some trouble with my script tag. I'm trying to include a
piece of PHP text via the script tag by doing so:

<script src="http://pinata.no-ip.org/~altmarvel/Scripts.php"></script>

This produces nothing, but I don't know why.


What are your exacts needs ?
If you want to include text produce by another web page, then <script
src...> is one of the solutions. Please read the recent thread
"Templates/inclusion in the new age" :

http://www.google.fr/groups?hl=fr&lr...com%26rnum%3D1

If you choose to use script, then your php page should send to the browser
correct mime type and javascript code (document.write(...) )

Jul 20 '05 #6

P: n/a
Pierre Goiffon wrote:
<snip>
... , then your php page should send to the
browser correct mime type and javascript code
(document.write(...) )


There is no correct mime type for client-side javascript source.
Browsers appear to ignore content type headers sent in the context of
script elements.

Richard.
Jul 20 '05 #7

P: n/a
li***************@yahoo.com (Liam Gibbs) wrote in message news:<62**************************@posting.google. com>...
I'm having some trouble with my script tag.


You're unclear about the differences between server-side and
client-side scripting.

PHP is server-side only. <script> is client-side only.

_If_ your PHP code's function is to _make_ a client-side script
(sometimes called "meta-scripting"), then you might have a client-side
<script> that refers to a piece of server-side PHP. But what the
<script> element is referring to is the _output_ of the PHP script,
not its source code.
Jul 20 '05 #8

P: n/a
In article <28*************************@posting.google.com> ,
di*****@codesmiths.com enlightened us with...
li***************@yahoo.com (Liam Gibbs) wrote in message news:<62**************************@posting.google. com>...
I'm having some trouble with my script tag.


You're unclear about the differences between server-side and
client-side scripting.

PHP is server-side only. <script> is client-side only.


Well, there _is_ a
<script runat="server">
for ASP.
--
--
~kaeli~
Acupuncture is a jab well done.
http://www.ipwebdesign.net/wildAtHeart
http://www.ipwebdesign.net/kaelisSpace

Jul 20 '05 #9

P: n/a
Ahhh.... I'm starting to see now. I was familiar with PHP, but not
with the SCRIPT tag. What I thought it would do is run the PHP on my
server, my server would spit the output to that page, and.... then a
whole bunch of stuff I was unclear about. I guess I have more muddling
to do now with JavaScript and so forth.

And I was unaware of the view-source thing. I'll also try that type
value.

Thanks all!
Jul 20 '05 #10

P: n/a
On Tue, 8 Jun 2004 13:04:06 -0500, kaeli <ti******@NOSPAM.comcast.net>
wrote:
Well, there _is_ a
<script runat="server">
for ASP.


I was hoping no-one would mention that - let's not confuse the poor
guy, OK ?

Jul 20 '05 #11

P: n/a
"Richard Cornford" <Ri*****@litotes.demon.co.uk> a écrit dans le
message de news:ca*******************@news.demon.co.uk
There is no correct mime type for client-side javascript source.
Browsers appear to ignore content type headers sent in the context of
script elements.


Yes, it seems there are not any "official" mime type meant to serve
JavaScript. But are you sure any mime type would fit in any browser ? I was
unclear about that, but unfortunatly haven't got enough time to test
yesterday evening.

In fact in a previous job we used JavaScript for external inclusion, these
JavaScript source were generated through ASP pages. As far as I can remember
we choosed to send something like application/x-javascript because some
browsers (probably NS4) absolutly wanted something different from the
default ASP text/html.
Her, I guess I'll test this evening...

Jul 20 '05 #12

P: n/a
James Moe wrote:
PHP is a server-side language interpreter.
I suppose you could try giving a "type" value, something like
type="text/php".


The type should match the MIME type of the scripting language used.
Whether the client-side scripting code (most probably Javascript code)
is a static file with a .js extension, or generated by PHP script on the
server, should not and does not matter to the browser.

The problem is that http://pinata.no-ip.org/~altmarvel/Scripts.php does
not return Javascript code but returns text/html, and no content.

--
Klaus Johannes Rusch
Kl********@atmedia.net
http://www.atmedia.net/KlausRusch/
Jul 20 '05 #13

P: n/a
Pierre Goiffon wrote:
Richard Cornford wrote:
There is no correct mime type for client-side javascript source.
Browsers appear to ignore content type headers sent in the
context of script elements.
Yes, it seems there are not any "official" mime type meant to
serve JavaScript.


After nine years of Internet javascript use it really feels like there
should be an official mime type doesn't it?
But are you sure any mime type would fit in any browser ?
I don't have access to all 40-odd javascript capable user agents, and it
was a couple of years ago that I tested this, but at the time I could
not get any browsers to refuse to handle JSP generated javascript as
javascript when sent with any of content-type header from a range that
included types that the browser would have had an attitude towards in
other contexts, unusual and very wrong types, and fictional mime types.
The browsers don't seem to care.

But how could they? Something isn't wrong until you judge what would be
right.
I was unclear about that, but unfortunatly haven't got enough
time to test yesterday evening.

In fact in a previous job we used JavaScript for external inclusion,
these JavaScript source were generated through ASP pages. As far as I
can remember we choosed to send something like
application/x-javascript because some browsers (probably NS4)
absolutly wanted something different from the default ASP text/html.
Her, I guess I'll test this evening...


Yes, that is exactly what happened to me. I was generating javascript
with JSP and a senior colleague told me to send text/javascript headers
with it, so I did. Later I was told on Usenet that it was nonsense so I
tried it out for myself and discovered that it was nonsense.

My experiment definitely included sending the content as text/html and
(Windows) Netscape 4 was among the test browser used. Also, in a couple
of years of regularly contributing to comp.lang.javascript, I have not
yet seen a javascript problem actually attributed to a content type
header on any browser or platform.

If you can find a browser that cares I would like to hear about it.

Richard.
Jul 20 '05 #14

P: n/a
Richard Cornford wrote:
There is no correct mime type for client-side javascript source.
But are you sure any mime type would fit in any browser ?
I was generating javascript
with JSP and a senior colleague told me to send text/javascript
headers with it, so I did. Later I was told on Usenet that it was
nonsense so I tried it out for myself and discovered that it was
nonsense.


Err well I guess I could now get exactly the same conclusion as you did.
Thanks a lot for your posts, I learnt something new ! Usenet is cool :)

--
Pour me répondre par mail privé, merci de supprimer _NOSPAM_ de mon
adresse.

Un grand merci à OE Quote Fix pour rendre OE utilisable :)
=> http://home.in.tum.de/~jain/software/oe-quotefix/

Jul 20 '05 #15

This discussion thread is closed

Replies have been disabled for this discussion.