如何引用*.js文件

zjzhz 2003-03-08 02:26:17
初学制作网页,请问我将一些JavaScript的特效代码存为*.js文件,如何在首页中引用这个js文件,最好有个实例,谢谢
...全文
373 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
ayuea 2003-09-07
  • 打赏
  • 举报
回复
怎么在html里面调用?用什么标签?举个例子吧
thrillers 2003-09-07
  • 打赏
  • 举报
回复
调用了js文件,里面的函数就能调用了
ayuea 2003-09-07
  • 打赏
  • 举报
回复
请问如何调用里面的函数?
afengfu 2003-09-06
  • 打赏
  • 举报
回复
Hi,大家好!
genuis 2003-03-09
  • 打赏
  • 举报
回复
<script language="javascript" src="incFile.js"></script>
如果你的默认客户端脚本是javascript 而且你的引用文件名是.js那么可以忽略language开关,使用
<script src="incFile.js"></script>

如果扩展名不是js,那么需要指定语言开关
<script language="javascript" src="incFile.zz"></script>
wsj 2003-03-09
  • 打赏
  • 举报
回复
SCRIPT Element | SCRIPT Object

--------------------------------------------------------------------------------

Specifies a script for the page that is interpreted by a script engine.

HTML Syntax

<SCRIPT
DEFER=defer
DISABLED=disabled
EVENT=event
FOR=for
ID=id
LANG=lang
LANGUAGE=language
SRC=src
TYPE=type
>
</SCRIPT>
Remarks

Code within the SCRIPT block that is not contained within a function is executed immediately as the page is loaded. To keep scripts from being displayed on down-level browsers, nest the SCRIPT block within a COMMENT block.

Script appearing after a FRAMESET element is ignored.

The SCRIPT element is a block element and requires a closing tag.

This element is available in HTML as of Microsoft?Internet Explorer 3.0, and in script as of Microsoft?Internet Explorer 4.0.

Members

AllAttributesPropertiesMethodsEventsCollectionsBehaviors Description
addBehavior Attaches a behavior to an <SCRIPT>.
all Returns a reference to the collection of elements contained by the <SCRIPT>.
applyElement Makes the <SCRIPT> either a child or parent of the <SCRIPT>.
attachEvent Binds the specified function to an event that fires on the <SCRIPT> when the function is called.
attributes Retrieves a collection of attributes of the object.
behaviorUrns Returns a collection of Uniform Resource Name (URN) strings identifying the behaviors attached to the <SCRIPT>.
canHaveHTML Retrieves the value indicating whether the <SCRIPT> can contain rich HTML markup.
childNodes Retrieves a collection of HTML Elements and TextNode objects that are direct descendants of the specified object.
children Retrieves a collection of DHTML Objects that are direct descendants of the <SCRIPT>.
clearAttributes Removes all attributes and values from the <SCRIPT>.
clientCaps Provides information about features supported by Microsoft® Internet Explorer, as well as a way for installing browser components on demand.
clientHeight Retrieves the height of the <SCRIPT> without taking into account any margin, border, scroll bar, or padding that might have been applied to the <SCRIPT>.
clientLeft Retrieves the distance between the offsetLeft property and the true left side of the client area.
clientTop Retrieves the distance between the offsetTop property and the true top of the client area.
clientWidth Retrieves the width of the <SCRIPT> without taking into account any margin, border, scroll bar, or padding that might have been applied to the <SCRIPT>.
cloneNode Copies a reference to the <SCRIPT> from the document hierarchy.
componentFromPoint Returns the component located at the specified coordinates.
contains Checks whether the given element is contained within the <SCRIPT>.
defer Sets or retrieves the status of the script.
detachEvent Unbinds the specified function from the event, so that the function stops receiving notifications when the event fires on the <SCRIPT>.
disabled Sets or retrieves the status of a control or style.
download Downloads a file and notifies a specified callback function when the download is complete.
dragDrop Initiates a drag event.
event Retrieves the event for which the script is written.
fireEvent Fires a specified event on the <SCRIPT>.
firstChild Retrieves a reference to the first child in the childNodes collection of the <SCRIPT>.
getAdjacentText Returns the adjacent text character.
getAttribute Retrieves the value of the specified attribute.
getElementsByTagName Retrieves a collection of objects based on the specified element name.
hasChildNodes Returns whether the <SCRIPT> has children.
homePage Contains information about a user's homepage.
htmlFor Retrieves the object that is bound to the event script.
id Retrieves the string identifying the <SCRIPT>.
innerHTML Sets or retrieves the HTML between the start and end tags of the <SCRIPT>.
innerText Sets or retrieves the text between the start and end tags of the <SCRIPT>.
insertAdjacentElement Inserts an element at the specified location.
isContentEditable Retrieves the value indicating whether the user can edit the contents of the <SCRIPT>.
isDisabled Retrieves the value indicating whether the user can interact with the <SCRIPT>.
isTextEdit Retrieves whether a TextRange <SCRIPT> can be created using the given object.
lang Sets or retrieves the language to use.
language Sets or retrieves the language in which the current script is written.
lastChild Retrieves a reference to the last child in the childNodes collection of an object.
mergeAttributes Copies all read/write attributes to the specified element.
nextSibling Retrieves a reference to the next child of the parent for the specified object.
nodeName Retrieves the name of a particular type of node.
nodeType Retrieves the type of the requested node.
nodeValue Sets or retrieves the value of a node.
onload Fires immediately after the browser loads the <SCRIPT>.
onpropertychange Fires when a property changes on the <SCRIPT>.
onreadystatechange Fires when the state of <SCRIPT> has changed.
parentElement Retrieves the parent object in the object hierarchy.
parentNode Retrieves the parent object in the document hierarchy.
parentTextEdit Retrieves the container object in the document hierarchy that can be used to create a TextRange containing the original <SCRIPT>.
previousSibling Retrieves a reference to the previous child of the parent for the specified object.
readyState Retrieves the current state of the <SCRIPT> being downloaded.
recordNumber Retrieves the ordinal record from the data set that generated the <SCRIPT>.
removeAttribute Removes the given attribute from the <SCRIPT>.
removeBehavior Detaches a behavior from the <SCRIPT>.
replaceAdjacentText Replaces the adjacent text character.
runtimeStyle Represents the cascaded format and style of the <SCRIPT> that overrides the format and style specified in global style sheets, inline styles, and HTML attributes.
saveSnapshot Enables the <SCRIPT> to persist data when a Web page is saved.
scopeName Retrieves the namespace defined for the element.
scrollHeight Retrieves the scrolling height of the <SCRIPT>.
scrollLeft Sets or retrieves the distance between the left edge of the <SCRIPT> and the leftmost portion of the content currently visible in the window.
scrollTop Sets or retrieves the distance between the top of the <SCRIPT> and the topmost portion of the content currently visible in the window.
scrollWidth Retrieves the scrolling width of the <SCRIPT>.
setAttribute Sets the value of the specified attribute.
sourceIndex Retrieves the ordinal position of the <SCRIPT>, in source order, as the <SCRIPT> appears in the all collection.
src Retrieves the URL to an external file that contains the source code or data.
style Represents the current settings of all possible inline styles for a given element.
swapNode Exchanges the location of two objects in the document hierarchy.
tagName Retrieves the tag name of the <SCRIPT>.
tagUrn Retrieves the Uniform Resource Name (URN) specified in the namespace declaration.
text Retrieves the text of the block <SCRIPT> as a string.
type Retrieves the MIME type for the associated scripting engine.
uniqueID Retrieves an auto-generated, unique identifier for the <SCRIPT>.

* denotes an extension to the W3C DOM.
alphalee 2003-03-09
  • 打赏
  • 举报
回复
不过尽量养成习惯,加上language="JavaScript"
在.JS文件里面,就不用加上上面的描述语言了,直接写代码。
zhanghk 2003-03-09
  • 打赏
  • 举报
回复
<script language = "javalanguage" src = "incFile.js"></script>
ysharp 2003-03-09
  • 打赏
  • 举报
回复
同意楼上的
Hackevin 2003-03-08
  • 打赏
  • 举报
回复
Oh,I'm sorry.
笔误,笔误……
xuzuning 2003-03-08
  • 打赏
  • 举报
回复
<script src="incFile.js"></script>
无版本声明时,language项可省略

引用vbs文件用
<script language="vbscript" src="incFile.vbs"></script>
lbd8848 2003-03-08
  • 打赏
  • 举报
回复
<script language="javascript" src="incFile.js"></script>
Hackevin 2003-03-08
  • 打赏
  • 举报
回复
<script language = "javalanguage" src = "incFile.js"></script>

87,910

社区成员

发帖
与我相关
我的任务
社区描述
Web 开发 JavaScript
社区管理员
  • JavaScript
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧