Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > Queston on script tag

Reply
Thread Tools

Queston on script tag

 
 
Torben Keil
Guest
Posts: n/a
 
      02-08-2008
Hello,

I try to load dynamic generated HTTP code into the browser.

Here's what I'm trying to do (very short written):
[DOCTYPE, html, head, title...]
<body>
<script type="text/html" charset="ISO-8859-1"
src="http://....../cgi-bin/code.pl"></script>
[...]
</body>
</html>

My perl script is located on an Internet server which executes this script
and returns clean HTML code with the right MIME-type.

But this all doesn't work on the web browser. If I use the same but as
javascript, it works.

May be you have a hint for me what I'm doing wrong?

Thanks in advance,
Torben
 
Reply With Quote
 
 
 
 
Harlan Messinger
Guest
Posts: n/a
 
      02-08-2008
Torben Keil wrote:
> Hello,
>
> I try to load dynamic generated HTTP code into the browser.
>
> Here's what I'm trying to do (very short written):
> [DOCTYPE, html, head, title...]
> <body>
> <script type="text/html" charset="ISO-8859-1"
> src="http://....../cgi-bin/code.pl"></script>
> [...]
> </body>
> </html>
>
> My perl script is located on an Internet server which executes this script
> and returns clean HTML code with the right MIME-type.


If you had

<script type="text/html">
<p>Hello, world!</p>
</script>

it wouldn't work either. The HTML inside the script tags is clean, the
script type is designated as text/html. Nevertheless, it won't work
because HTML isn't script and the browser doesn't have any way to
execute it as script.

> But this all doesn't work on the web browser. If I use the same but as
> javascript, it works.


Because Javascript is script and the browser knows how to execute it.
 
Reply With Quote
 
 
 
 
Andy Dingley
Guest
Posts: n/a
 
      02-08-2008
On 8 Feb, 15:42, Torben Keil <torben_k...@web.de> wrote:

> My perl script is located on an Internet server


Where?
 
Reply With Quote
 
Jeff
Guest
Posts: n/a
 
      02-08-2008
Torben Keil wrote:
> Hello,
>
> I try to load dynamic generated HTTP code into the browser.
>
> Here's what I'm trying to do (very short written):
> [DOCTYPE, html, head, title...]
> <body>
> <script type="text/html" charset="ISO-8859-1"
> src="http://....../cgi-bin/code.pl"></script>
> [...]
> </body>
> </html>
>
> My perl script is located on an Internet server which executes this script
> and returns clean HTML code with the right MIME-type.


If you run "head" on that script what mime type does it return?

I don't seem to have head on my XP box, but I've had it on every other
OS, anyone know how to add it?

Jeff
>
> But this all doesn't work on the web browser. If I use the same but as
> javascript, it works.
>
> May be you have a hint for me what I'm doing wrong?
>
> Thanks in advance,
> Torben

 
Reply With Quote
 
richard
Guest
Posts: n/a
 
      02-10-2008
On Fri, 08 Feb 2008 16:42:05 +0100, Torben Keil <>
wrote:

>Hello,
>
>I try to load dynamic generated HTTP code into the browser.
>
>Here's what I'm trying to do (very short written):
>[DOCTYPE, html, head, title...]
> <body>
> <script type="text/html" charset="ISO-8859-1"
>src="http://....../cgi-bin/code.pl"></script>
>[...]
> </body>
></html>
>
>My perl script is located on an Internet server which executes this script
>and returns clean HTML code with the right MIME-type.
>
>But this all doesn't work on the web browser. If I use the same but as
>javascript, it works.
>
>May be you have a hint for me what I'm doing wrong?
>
>Thanks in advance,
>Torben



There is no "text/html".
charset is totally placed wrong.
"src=" Huh? What are you trying to call?
If anything, you would use a relative link.

I would suggest you contact your host and ask them why it does not
work.

 
Reply With Quote
 
Andy Dingley
Guest
Posts: n/a
 
      02-10-2008
On 10 Feb, 05:09, richard <I.dont.c...@do.you> wrote:
> On Fri, 08 Feb 2008 16:42:05 +0100, Torben Keil <torben_k...@web.de>
> wrote:


> > <script type="text/html" charset="ISO-8859-1"
> >src="http://....../cgi-bin/code.pl"></script>


> There is no "text/html".
> charset is totally placed wrong.
> "src=" Huh? What are you trying to call?
> If anything, you would use a relative link.


Ah, Mr Bullis, we meet again and you're still no wiser.For the sake of
the OP who might not realise that you're the infamous "Richard The
Stupid" (just Google it), the trolls' friend and the truckers' VK,
here's a few pointers:


First off, read the W3C spec:
<http://www.w3.org/TR/html401/interact/scripts.html#edef-SCRIPT>

"text/html" is a perfectly legitimate MIME content-type, as usually
served through a HTTP header. It means HTML though, not JavaScript, so
it's the wrong value in this case. The OP should use "text/javascript"
instead, because the content that his Perl script is producing is
intended to be JavaScript.

Most importantly though, that server-side Perl script should return it
too, and return it correctly as "text/javascript".

charset is perfectly correct. It's a valid attribute on <script>, it's
a valid value. Personally I'd use utf-8 instead, and I'd ignore this
attribute and just let the target script set it in a HTTP header.
However the OP isn't _wrong_ here.

The src attribute is also fine. It refers to a CGI script on a server,
and probably a Perl script. Now the idea of generating JavaScript from
Perl strikes me as over-complex, hard to debug, and probably not a
good idea, but it's the OP's problem to worry about that level.

"use a relative link" is the one place where you're not crudely wrong,
but then even a broken clock is right twice a day.

A relative URL would probably be a bit easier for long-term
maintenance, as it doesn't embed a domain or hostname than might
change in the future. However this should be a relative URL using an
abs_path (beginning with "/" such as /scripts/my_project/foo.pl )_ and
_not_ as you'd probably do it with a rel_path beginning "../" or
similar. Those can, and likely will be, be very awkward to maintain as
content is moved around directories.

 
Reply With Quote
 
Torben Keil
Guest
Posts: n/a
 
      02-11-2008
Andy Dingley wrote:

> [...]
> "text/html" is a perfectly legitimate MIME content-type, as usually
> served through a HTTP header. It means HTML though, not JavaScript, so
> it's the wrong value in this case. The OP should use "text/javascript"
> instead, because the content that his Perl script is producing is
> intended to be JavaScript.


My Perl-Script returns clean HTML code. That's why I decided to use
"text/html" as MIME type. And using "application/JavaScript" is working
when I'm linking to JavaScript code on the remote server.

But I whish to embedd the produced HTML code of the perl script in the
website.

> [...]


Greetings,
Torben
 
Reply With Quote
 
Torben Keil
Guest
Posts: n/a
 
      02-11-2008
Harlan Messinger wrote:

> [...]
>
> If you had
>
> <script type="text/html">
> <p>Hello, world!</p>
> </script>
>
> it wouldn't work either. The HTML inside the script tags is clean, the
> script type is designated as text/html. Nevertheless, it won't work
> because HTML isn't script and the browser doesn't have any way to
> execute it as script.
>
>> But this all doesn't work on the web browser. If I use the same but as
>> javascript, it works.

>
> Because Javascript is script and the browser knows how to execute it.


Okay JavaScript has to be executed. But a browser should normally know how
to handle HTML...?

Is this possibility of embedding of HTML in a website via the script tag
forbidden? Maybe you or someone else can tell me why this must not work?

Greetings,
Torben

 
Reply With Quote
 
Harlan Messinger
Guest
Posts: n/a
 
      02-11-2008
Torben Keil wrote:
> Harlan Messinger wrote:
>
>> [...]
>>
>> If you had
>>
>> <script type="text/html"> <p>Hello, world!</p> </script>
>>
>> it wouldn't work either. The HTML inside the script tags is clean,
>> the script type is designated as text/html. Nevertheless, it won't
>> work because HTML isn't script and the browser doesn't have any way
>> to execute it as script.
>>
>>> But this all doesn't work on the web browser. If I use the same
>>> but as javascript, it works.

>> Because Javascript is script and the browser knows how to execute
>> it.

>
> Okay JavaScript has to be executed. But a browser should normally
> know how to handle HTML...?


Sure, in places where it expects HTML. Then you tell it, "OK, here's
some script to execute," but you turn around and give it something that
isn't executable script, and expect the browser magically to know that
you really didn't mean what you said. You can't just make stuff up and
then expect it to work.

> Is this possibility of embedding of HTML in a website via the script
> tag forbidden? Maybe you or someone else can tell me why this must
> not work?


It has nothing to do with anything being *forbidden*. A SCRIPT tag means
what it means. By using one you're telling the browser "Here's some
script I want you to execute", but then you're giving it something that
isn't executable script. The browser isn't going to realize what's going
on and look at you with a sly grin and say, "Oh, you silly, you played a
*trick* on me" and then ignore the SCRIPT tag and do what you hoped it
would do.
 
Reply With Quote
 
Bergamot
Guest
Posts: n/a
 
      02-11-2008
Torben Keil wrote:
>
> I whish to embedd the produced HTML code of the perl script in the
> website.


http://www.google.com/search?q=how%2...pt%20in%20html

A perl newsgroup may be more helpful, maybe comp.lang.perl.misc

--
Berg
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Newbie's queston on taking pictures Satoshi Digital Photography 15 04-25-2006 02:12 AM
how do u invoke Tag b's Tag Handler from within Tag a's tag Handler? shruds Java 1 01-27-2006 03:00 AM
Queston about the D70 Ted Digital Photography 2 04-18-2004 02:21 AM
Queston about addition in Maxplus II lezah VHDL 7 03-02-2004 06:11 PM
Win XP Queston, How to set up IE for multiple users? Bob Computer Support 5 11-16-2003 03:23 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57