放到一个web页面中,通知调用这个web页面来调用,且通过传参数等形式来控制调用个数

解决方案 »

  1.   

    在js文件中
    document.wriet输出
    <script src='1.js'></script>
      

  2.   

    保存为一个文件名为.js的文件,保存在项目中,然后在需要调用的页面进行引用,如:
    <script src="<c:url value='/*/*.js'/>" type="text/javascript"></script>
    然后就可以直接引用你的方程了
      

  3.   

    动态引用js. 
    在页面中,用js代码控制js文件的src路径.
      

  4.   

    有个简单的方法是服务器端合并<script src='js.asp?file=js1|js2|js3'></script>在服务器端,js.asp文件只需要根据file参数把相关文件内容输出就可以
    比如
    Dim fstr
    fstr="|" & Trim(Request.QueryString("file")) & "|"
    If InStr(fstr,"js1") Then
    <!--#include file="js1.js"-->
    End If
    If InStr(fstr,"js2") Then
    <!--#include file="js2.js"-->
    End If
    If InStr(fstr,"js3") Then
    <!--#include file="js3.js"-->
    End If
    If InStr(fstr,"js4") Then
    <!--#include file="js4.js"-->
    End If或者用文件操作函数动态读取文件内容并输出.其实直接在浏览器端动态加载JS文件是最好的.
      

  5.   

    Shit 这也会写错代码Dim fstr 
    fstr="|" & Trim(Request.QueryString("file")) & "|" 
    If InStr(fstr,"|js1|")>0 Then 
    <!--#include file="js1.js"--> 
    End If 
    If InStr(fstr,"|js2|")>0 Then 
    <!--#include file="js2.js"--> 
    End If 
    If InStr(fstr,"|js3|")>0 Then 
    <!--#include file="js3.js"--> 
    End If 
    If InStr(fstr,"|js4|")>0 Then 
    <!--#include file="js4.js"--> 
    End If 
    这个很好说了,我这上面的代码就是例子.
      

  6.   

    nanyang9你的代码是vb.net里的吧
    js里怎么操作
      

  7.   

    如果你的网站是ASP空间,那建立一个下面的文件
    '文件名: js.asp
    Dim fstr 
    fstr="|" & Trim(Request.QueryString("file")) & "|" 
    If InStr(fstr,"|js1|")>0 Then 
    <!--#include file="js1.js"--> 
    End If 
    If InStr(fstr,"|js2|")>0 Then 
    <!--#include file="js2.js"--> 
    End If 
    If InStr(fstr,"|js3|")>0 Then 
    <!--#include file="js3.js"--> 
    End If 
    If InStr(fstr,"|js4|")>0 Then 
    <!--#include file="js4.js"--> 
    End If然后在HTML页面调用的时候这样调用<script type="text/javascript" src="js.asp?file=js1.js|js2.js|js4.js"></script>似乎看起来步骤比较多,但使用的时候,HTML代码看起来比较清爽
      

  8.   

    汗,还是写错了<%@LANGUAGE="VBSCRIPT" CODEPAGE="936"%>
    <%
    '文件名: js.asp
    Dim fstr
    fstr="|" & Trim(Request.QueryString("file")) & "|"
    If InStr(fstr,"|js1|")>0 Then
    %>
    <!--#include file="js1.js"--> 
    <%
    End If 
    If InStr(fstr,"|js2|")>0 Then 
    %>
    <!--#include file="js2.js"--> 
    <%
    End If 
    If InStr(fstr,"|js3|")>0 Then 
    %>
    <!--#include file="js3.js"--> 
    <%
    End If 
    If InStr(fstr,"|js4|")>0 Then
    %>
    <!--#include file="js4.js"--> 
    <%
    End If
    %>
    <!--- 文件名: test.htm --->
    <script type="text/javascript" src="js.asp?file=js1.js|js2.js|js4.js"></script>
    如果你是纯HTML网站,那只有在<head>区域通过JS进行条件判断后使用document.wriet()方法输出想要加载的JS文件.
    网上有也很多动态加载JS文件的方法,具体可以去看各HTML编辑器里的JS的加载方法.
      

  9.   

    我想问的是有没有用js或ajax方式处理完成,而不是用服务器端判断,这样减少资源使用
      

  10.   

    模拟使用命名空间的方法,common.js
    function nameSapce1(){
        alert(1);
        fun1 = function(){
            alert("namespace1::func1");
        };
    }function nameSpace2(){
        alert(2);
        fun1 = function(){
            alert("namespace2::func1");
        };
        fun2 = function(){
            alert("namespace2::func2");
        };
    }function nameSpace3(){
        alert(3);
    }function nameSpace4(){
        alert(4);
    }html代码
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
        <head>
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
            <SCRIPT language="JavaScript">
            </script>
            <SCRIPT language="JavaScript">
            var fn = new nameSapce1();
            fun1();
    fun2();
        </script>
        </head>
        <body>
        </body>
    </html>
      

  11.   

    上例中,可以看到,虽然在多个命名空间都有函数和调用。
    但只有被实例化的nameSpace1中是代码是有效的。