无法从Include文件中获取函数 [英] Can't get Function to run from Include file

查看:65
本文介绍了无法从Include文件中获取函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个.shtml文件,显示照片,我希望将一些

功能传递给Include文件,以便重复使用。

不幸的是,它's不工作。


这是.shtml文件的一部分:


======

<! - #include file =" /tmb8/functions.inc" - >

< script type =" text / javascript">

var title =" Noosa,Australia - October / November 2003"

..

..

..

displayphotos(photoarray,args,photosinarow)

======


这是functions.inc:


========

<%

功能displayphotos(photoarray,args,photosinarow)

document.write(" hello,world< br>")

结束函数

%>

=== =======


首先,我只是想看看Hello,World,但我什么也没得到 - 页面

http://www.solotraveller.com/tmb8/tm...03/index.shtml


我认为我把#include语句放在了错误的地方。

我能够让函数更早地运行,但是它们被称为。/ b
来自.asp文件,而不是.shtml文件。

解决方案

Peter Bassett写道:


我有一个.shtml文件,显示照片,我希望将一些
功能传递给Include文件,以便重用。
不幸的是,它'不工作。

这是.shtml文件的一部分:

======
<! - #include file = " /tmb8/functions.inc" - >
< script type =" text / javascript">
var title =" Noosa,Australia - October / November 2003"



displayphotos(photoarray,args,照片inarow)
======

这是functions.inc:

========
<%
function displayphotos(photoarray,args,photosinarow)
document.write(" hello,world< br>")
结束函数
%>
== ========

首先,我只是想看看Hello,World,但我什么也没得到 - 页面
位于 http://www.solotraveller.com/tmb8/tm...03/index.shtml

我认为我把#include语句放在了错误的地方。
我已经能够让函数更早地工作了,但它们被称为
来自.asp文件,而不是.shtml文件。



语法问题:


内联(即包含在HTML文档中)javascript函数

工作语法应该是:


< SCRIPT TYPE =" text / javascript" LANGUAGE =" javascript">

function displayphotos(photoarray,args,photosinarow){

document.write(''hello,world< br>'');

}

< / SCRIPT>


Gr,Juliette


< blockquote> Peter Bassett写道:

<! - #include file =" /tmb8/functions.inc" - >


这是在服务器上执行

< script type =" text / javascript">
displayphotos(photoarray,args,photosinarow )


这是在客户端执行

这是functions.inc:
<%
function displayphotos(photoarray,args ,photosinarow)
document.write(" hello,world< br>")
结束函数
%>




这是在服务器上执行的。


您无法使用客户端来调用服务器环境中的函数

脚本。您必须向服务器发出新请求,通常使用

表格或链接。


-

David Dorward http://dorward.me.uk/


Juliette于2003年11月16日写道:


< snip>

用于内联(即包含在HTML中)文档)javascript
函数的工作语法应该是:

< SCRIPT TYPE =" text / javascript" LANGUAGE =" javascript">




这是不正确的。 语言属性已经被弃用了近乎五年的时间。不应该使用它。虽然这是无关紧要的

(对我之前的声明做),但语言属性应包括

SCRIPT块包含的JavaScript版本。指定

" JavaScript"表示JavaScript v1.0对象,方法和

语句如下(这可能不是这种情况)。


最后一点。您还忽略了将JavaScript代码包装在

HTML注释中(<!--...-->)。


Mike


-

Michael Winter

M.Winter @ [no-spam] blueyonder.co.uk(删除[no-spam]回复)


I have a .shtml file, that displays photos, in which I wish to pass some
functionality off to an Include file for reusability purposes.
Unfortunately, it''s not working.

Here is a portion of the .shtml file:

======
<!--#include file="/tmb8/functions.inc"-->
<script type="text/javascript">
var title = "Noosa, Australia - October / November 2003"
..
..
..
displayphotos(photoarray, args, photosinarow)
======

Here is functions.inc:

========
<%
function displayphotos(photoarray, args, photosinarow)
document.write("hello, world<br>")
end function
%>
==========

To start, I just want to see Hello, World but I just get nothing - the page
is at http://www.solotraveller.com/tmb8/tm...03/index.shtml

I think I''m putting the #include statement in the wrong place.
I have been able to get functions to work earlier, but they were called
from .asp files, not .shtml files.

解决方案

Peter Bassett wrote:


I have a .shtml file, that displays photos, in which I wish to pass some
functionality off to an Include file for reusability purposes.
Unfortunately, it''s not working.

Here is a portion of the .shtml file:

======
<!--#include file="/tmb8/functions.inc"-->
<script type="text/javascript">
var title = "Noosa, Australia - October / November 2003"
.
.
.
displayphotos(photoarray, args, photosinarow)
======

Here is functions.inc:

========
<%
function displayphotos(photoarray, args, photosinarow)
document.write("hello, world<br>")
end function
%>
==========

To start, I just want to see Hello, World but I just get nothing - the page
is at http://www.solotraveller.com/tmb8/tm...03/index.shtml

I think I''m putting the #include statement in the wrong place.
I have been able to get functions to work earlier, but they were called
from .asp files, not .shtml files.


Syntax problem:

For inline (i.e. included in a HTML document) javascript functions to
work the syntax should be:

<SCRIPT TYPE="text/javascript" LANGUAGE="javascript">
function displayphotos(photoarray, args, photosinarow) {
document.write(''hello, world<br>'');
}
</SCRIPT>

Gr, Juliette


Peter Bassett wrote:

<!--#include file="/tmb8/functions.inc"-->
This is executed on the server
<script type="text/javascript">
displayphotos(photoarray, args, photosinarow)
This is executed on the client
Here is functions.inc:
<%
function displayphotos(photoarray, args, photosinarow)
document.write("hello, world<br>")
end function
%>



This is executed on the server.

You can not call a function in the server environment using client side
scripting. You have to make a new request to the server, typically using a
form or a link.

--
David Dorward http://dorward.me.uk/


Juliette wrote on 16 Nov 2003:

<snip>

For inline (i.e. included in a HTML document) javascript
functions to work the syntax should be:

<SCRIPT TYPE="text/javascript" LANGUAGE="javascript">



That is incorrect. The ''language'' attribute has been deprecated for
almost five years. It should not be used. Although this is irrelevant
(do to my previous statement), the language attribute should include
the version of JavaScript that the SCRIPT block contains. Specifying
"JavaScript" indicates that JavaScript v1.0 objects, methods and
statements follow (and this is probably not the case).

One last point. You also neglected to wrap the JavaScript code in
HTML comments (<!--...-->).

Mike

--
Michael Winter
M.Winter@[no-spam]blueyonder.co.uk (remove [no-spam] to reply)


这篇关于无法从Include文件中获取函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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