怎么样下载js

JavaScript09

怎么样下载js,第1张

你是要下载HTML网页中的js么?

用chrome访问网页,viewsource查看网页源代码,找到要下载的js文件,点击就打开了,然后拷贝或者另存就行。

浏览器都有查看网页源代码功能的

代码如下:

<html>

<head>

<meta http-equiv="Content-Type" content="text/htmlcharset=gbk" />

<title>JS实现下载文件</title>

<script language=JavaScript>

function download(obj){

if(document.all.ifrm==null){

objIframe=document.createElement("IFRAME")

document.body.insertBefore(objIframe)

objIframe.outerHTML="<iframe name=ifrm style='width:0hieght:0' src="+obj.href+"></iframe>"

re=setTimeout("download()",1)

}

else{

clearTimeout(re)

files=window.open(obj.href,"ifrm")

files.document.execCommand("SaveAs")

document.all.ifrm.removeNode(true)

}}

</script>

</head>

<body >

文档列表:请点出下载<br/>

<a href="file01.doc" id="filelist" onclick="download()return false" style="cursor:hand">文件1</a> <br/>

<a href="file02.pdf" id="filelist" onclick="download()return false" style="cursor:hand">文件2</a>

</body>

</html>