从.pl文件生成的javascript [英] Generated javascript from .pl files

查看:111
本文介绍了从.pl文件生成的javascript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,


我正在尝试使用Internet Explorer 6.0中的一些javascript代码,这是由Perl文件生成的
。我的标题中有一行看起来像这样:
< script src =" jscode.pl?parm1 = foo& parm2 =猴"类型= QUOT;文本/ JavaScript的" /

Hi all,

I''m trying to use some javascript code in Internet Explorer 6.0 that''s
being generated by a Perl file. I have a line in my header that looks
something like this:

<script src="jscode.pl?parm1=foo&parm2=monkey" type="text/javascript" /


>
>



为了简单起见,这里是一个非常简化的版本

Perl代码:


print" Content-Type:text / javascript; charset = ISO-8859-1 \ n \ n";

print" alert(''Testing,1-2-3!''); \ n" ;;

Perl代码返回带有mime类型text / javascript的标头。 (我已经

尝试了应用程序/ javascript无济于事。)一切都运行良好的

Firefox,我收到一个消息框,上面写着Testing,1- 2-3"!;当我加载页面时弹出

。但是,在Internet Explorer 6.0中,即使手动提取URL的结果看起来很好,

代码也没有执行。没有消息框,没有错误,没有任何消息。这是

默默死亡。


我认为问题在于Internet Explorer正在看到.pl

扩展名和思考,嗯,这不是一个Javascript文件!和

绕过它。它可能与此有关:
http ://msdn2.microsoft.com/en-us/library/ms775148.aspx


有谁知道我能做些什么来获得Perl脚本将

被Internet Explorer读取为合法的javascript文件?

我在服务器上有什么特别的东西(Win2k3上的IIS 6.0

服务器)?或者它是否显然不可能?

Just for the sake of simplicity, here''s a very simplified version of
the Perl code:

print "Content-Type: text/javascript; charset=ISO-8859-1\n\n";
print "alert(''Testing, 1-2-3!'');\n";
The Perl code returns a header with mime type text/javascript. (I''ve
tried application/javascript to no avail.) Everything works great in
Firefox, and I get a message box that says "Testing, 1-2-3!" that pops
up when I load the page. However, in Internet Explorer 6.0, even
though the results of pulling up the URL manually looks great, the
code isn''t executing. No message box, no errors, no nothing. It''s
silently dying.

I think the problem is that Internet Explorer is seeing the .pl
extension and thinking, "Hmm, that''s not a Javascript file!" and
bypassing it. It might have something to do with this:
http://msdn2.microsoft.com/en-us/library/ms775148.aspx

Does anyone know if there''s anything I can do to get a Perl script to
be read by Internet Explorer as a legitimate javascript file? Is
there something special I have to do on the server (IIS 6.0 on Win2k3
Server)? Or is it just plain not possible?

推荐答案

TonyV在2007年8月7日下午6:57发表以下内容:
TonyV said the following on 8/7/2007 6:57 PM:

大家好,


我正试图在Internet Explorer 6.0中使用一些javascript代码,这是

由Perl文件生成。我的标题中有一行看起来像这样:
< script src =" jscode.pl?parm1 = foo& parm2 =猴"类型= QUOT;文本/ JavaScript的" /


为了简单起见,这里是一个非常简化的版本

Perl代码:


print" Content-Type:text / javascript; charset = ISO-8859-1 \ n \ n";

print" alert(''Testing,1-2-3!''); \ n" ;;


Perl代码返回带有mime类型text / javascript的标头。 (我已经

尝试了应用程序/ javascript无济于事。)一切都运行良好的

Firefox,我收到一个消息框,上面写着Testing,1- 2-3"!;当我加载页面时弹出

。但是,在Internet Explorer 6.0中,即使手动提取URL的结果看起来很好,

代码也没有执行。没有消息框,没有错误,没有任何消息。这是

默默死亡。


我认为问题在于Internet Explorer正在看到.pl

扩展名和思考,嗯,这不是一个Javascript文件!和

绕过它。它可能与此有关:
http ://msdn2.microsoft.com/en-us/library/ms775148.aspx


有谁知道我能做些什么来获得Perl脚本将

被Internet Explorer读取为合法的javascript文件?

我在服务器上有什么特别的东西(Win2k3上的IIS 6.0

服务器)?或者这是不可能的?
Hi all,

I''m trying to use some javascript code in Internet Explorer 6.0 that''s
being generated by a Perl file. I have a line in my header that looks
something like this:

<script src="jscode.pl?parm1=foo&parm2=monkey" type="text/javascript" /

Just for the sake of simplicity, here''s a very simplified version of
the Perl code:

print "Content-Type: text/javascript; charset=ISO-8859-1\n\n";
print "alert(''Testing, 1-2-3!'');\n";
The Perl code returns a header with mime type text/javascript. (I''ve
tried application/javascript to no avail.) Everything works great in
Firefox, and I get a message box that says "Testing, 1-2-3!" that pops
up when I load the page. However, in Internet Explorer 6.0, even
though the results of pulling up the URL manually looks great, the
code isn''t executing. No message box, no errors, no nothing. It''s
silently dying.

I think the problem is that Internet Explorer is seeing the .pl
extension and thinking, "Hmm, that''s not a Javascript file!" and
bypassing it. It might have something to do with this:
http://msdn2.microsoft.com/en-us/library/ms775148.aspx

Does anyone know if there''s anything I can do to get a Perl script to
be read by Internet Explorer as a legitimate javascript file? Is
there something special I have to do on the server (IIS 6.0 on Win2k3
Server)? Or is it just plain not possible?



你能建立一个测试页面,使用那些可用不同配置进行测试的代码吗?我只是用.pl

扩展名手动测试IE7,它给了我一个外部文件没问题。


-

Randy

机会有利于准备好的心灵

comp.lang.javascript常见问题 - http://jibbering.com/faq/index.html

Javascript最佳实践 - http://www.JavascriptToolbox.com/bestpractices/


On 8月7日下午6:57,TonyV< kingskip ... @ gmail.comwrote:
On Aug 7, 6:57 pm, TonyV <kingskip...@gmail.comwrote:

大家好,


我正在尝试在Internet Explorer 6.0中使用一些由Perl文件生成的
的javascript代码。我的标题中有一行看起来像这样:
< script src =" jscode.pl?parm1 = foo& parm2 =猴"类型= QUOT;文本/ JavaScript的" /


为了简单起见,这里是一个非常简化的版本

Perl代码:


print" Content-Type:text / javascript; charset = ISO-8859-1 \ n \ n";

print" alert(''Testing,1-2-3!''); \ n" ;;
Hi all,

I''m trying to use some javascript code in Internet Explorer 6.0 that''s
being generated by a Perl file. I have a line in my header that looks
something like this:

<script src="jscode.pl?parm1=foo&parm2=monkey" type="text/javascript" /

Just for the sake of simplicity, here''s a very simplified version of
the Perl code:

print "Content-Type: text/javascript; charset=ISO-8859-1\n\n";
print "alert(''Testing, 1-2-3!'');\n";



错误的MIME类型,尽管type属性似乎意味着什么。

Wrong MIME type, despite what the type attribute would seem to imply.


Perl代码返回一个标题mime type text / javascript。 (我已经

尝试了应用程序/ javascript无效。)一切正常工作
The Perl code returns a header with mime type text/javascript. (I''ve
tried application/javascript to no avail.) Everything works



尝试application / x-javascript。


很棒的

Try application/x-javascript.

great in


Firefox,我收到一个消息框,上面写着Testing,1-2-3!当我加载页面时弹出

。但是,在Internet Explorer 6.0中,即使手动提取URL的结果看起来很好,

代码也没有执行。没有消息框,没有错误,没有任何消息。这是

默默死亡。


我认为问题在于Internet Explorer正在看到.pl

扩展名和思考,嗯,这不是一个Javascript文件!和
Firefox, and I get a message box that says "Testing, 1-2-3!" that pops
up when I load the page. However, in Internet Explorer 6.0, even
though the results of pulling up the URL manually looks great, the
code isn''t executing. No message box, no errors, no nothing. It''s
silently dying.

I think the problem is that Internet Explorer is seeing the .pl
extension and thinking, "Hmm, that''s not a Javascript file!" and



用户代理不确定扩展名中的MIME类型。无论如何,URI都是

而不是文件路径。服务器将请求的URI映射到文件路径或

进程,并在某些情况下将文件扩展名映射到MIME类型以进行

响应。

User agents do not determine MIME types from extensions. URI''s are
not file paths anyway. Servers map requested URI''s to file paths or
processes and in some cases map file extensions to MIME types for
responses.


绕过它。它可能与此有关: http:// msdn2 .microsoft.com / zh-CN / library / ms775148.aspx



No.

No.


有没有人知道我能做些什么才能获得一个Perl脚本

被Internet Explorer读作合法的javascript文件?

我在服务器上有什么特别的东西(Win2k3上的IIS 6.0

服务器)?或者这是不可能的?
Does anyone know if there''s anything I can do to get a Perl script to
be read by Internet Explorer as a legitimate javascript file? Is
there something special I have to do on the server (IIS 6.0 on Win2k3
Server)? Or is it just plain not possible?



很有可能。查看您的脚本声明:


< script src =" jscode.pl?parm1 = foo& parm2 = monkey" type =" text /

javascript" /


我假设标记在斜杠后关闭,所以你应该意识到

你不能在脚本元素中使用自闭标签。更改为:


< script src =" jscode.pl?parm1 = foo& parm2 = monkey" type =" text /

javascript">< / script>


修复它和MIME类型,它应该可以正常工作。如果没有,请发布一个

样本页面的链接。

It is quite possible. Looking at your script declaration:

<script src="jscode.pl?parm1=foo&parm2=monkey" type="text/
javascript" /

I assume the tag is closed after the slash, so you should realize that
you cannot use self-closing tags with script elements. Change to:

<script src="jscode.pl?parm1=foo&parm2=monkey" type="text/
javascript"></script>

Fix that and the MIME type and it should work fine. Post a link to a
sample page if not.


TonyV写道:
TonyV wrote:

我正在尝试使用Internet Explorer 6.0中的一些javascript代码,它们是由Perl文件生成的。
。我的标题中有一行看起来像这样:
< script src =" jscode.pl?parm1 = foo& parm2 =猴"类型= QUOT;文本/ JavaScript的" /
I''m trying to use some javascript code in Internet Explorer 6.0 that''s
being generated by a Perl file. I have a line in my header that looks
something like this:

<script src="jscode.pl?parm1=foo&parm2=monkey" type="text/javascript" /



--------------------------------- --------------------------------------- ^

------------------------------------------------------------------------^


为了简单起见,这里是一个非常简化的版本

Perl代码:


print" Content-输入:text / javascript; charset = ISO-8859-1 \ n \ n";

print" alert(''Testing,1-2-3!''); \ n" ;;


[...]但是,在Internet Explorer 6.0中,即使是手动提取URL的结果也很好,



代码没有执行。没有消息框,没有错误,没有任何消息。这是

默默死亡。


我认为问题在于Internet Explorer正在看到.pl

扩展名和思考,嗯,这不是一个Javascript文件!和

绕过它。它可能与此有关:
http ://msdn2.microsoft.com/en-us/library/ms775148.aspx



我发现你的伪XHTML更有可能(见上面的标记)

导致问题。 IE不支持X(HT)ML,因此`script''元素

不会结束。但是,如果使用HTML而不能解决问题:

您不需要将Perl生成的内容作为资源提供.pl

后缀;事实上,建议不要这样做;使用内容协商

代替(为什么不.js.pl,并使用.js?)。 [1]

PointedEars

___________

[1] http://www.w3.org/QA/Tips/uri-choose pp。,尤其是
http://www.w3.org/Provider/Style/URI

-

现实主义:HTML 4.01严格

福音:XHTML 1.0严格

疯狂:XHTML 1.1 as application / xhtml + xml

- Bjoern Hoehrmann

I find it more likely that your pseudo-XHTML (see the marker above) is
causing the problem. IE does not support X(HT)ML, so the `script'' element
does not end. However, if using HTML instead does not solve the problem:
You are not required to serve Perl-generated content as resource with a .pl
suffix; in fact, it is recommended not to do so; use content negotiation
instead (why not .js.pl, and using .js?). [1]
PointedEars
___________
[1] http://www.w3.org/QA/Tips/uri-choose pp., especially
http://www.w3.org/Provider/Style/URI
--
realism: HTML 4.01 Strict
evangelism: XHTML 1.0 Strict
madness: XHTML 1.1 as application/xhtml+xml
-- Bjoern Hoehrmann


这篇关于从.pl文件生成的javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆