Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   HTML (http://www.velocityreviews.com/forums/f31-html.html)
-   -   Queston on script tag (http://www.velocityreviews.com/forums/t590390-queston-on-script-tag.html)

Torben Keil 02-08-2008 03:42 PM

Queston on script tag
 
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

Harlan Messinger 02-08-2008 03:56 PM

Re: Queston on script tag
 
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.

Andy Dingley 02-08-2008 03:59 PM

Re: Queston on script tag
 
On 8 Feb, 15:42, Torben Keil <torben_k...@web.de> wrote:

> My perl script is located on an Internet server


Where?

Jeff 02-08-2008 08:16 PM

Re: Queston on script tag
 
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


richard 02-10-2008 05:09 AM

Re: Queston on script tag
 
On Fri, 08 Feb 2008 16:42:05 +0100, Torben Keil <torben_keil@web.de>
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.


Andy Dingley 02-10-2008 12:31 PM

Re: Queston on script tag
 
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.


Torben Keil 02-11-2008 07:54 AM

Re: Queston on script tag
 
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

Torben Keil 02-11-2008 07:59 AM

Re: Queston on script tag
 
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


Harlan Messinger 02-11-2008 11:53 AM

Re: Queston on script tag
 
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.

Bergamot 02-11-2008 11:57 AM

Re: Queston on script tag
 
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


All times are GMT. The time now is 08:31 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.