在ASP中调用HTML以调用其他脚本
Calling HTML within ASP to call other scripts
我正在开发sharepoint,并在我的文件中嵌入了jquery、谷歌图表、角库调用。但是,当我需要添加或删除内容时,返回SharePoint设计器并编辑母版页将成为一个乏味的过程。
这就是我所拥有的:
<asp:ScriptManager id="ScriptManager" runat="server" EnablePageMethods="false" EnablePartialRendering="true" EnableScriptGlobalization="false" EnableScriptLocalization="true">
<Scripts>
<%-- Libraries/Addons Nov27/13 --%><asp:ScriptReference Path="/Style Library/libs/jquery-1.10.2.min.js"></asp:ScriptReference>
<asp:ScriptReference Path="/Style Library/libs/jquery-ui.min.js"></asp:ScriptReference>
<asp:ScriptReference Path="https://www.google.com/jsapi"></asp:ScriptReference>
<asp:ScriptReference Path="/Style Library/libs/jquery.SPServices-2013.01.min.js"></asp:ScriptReference>
<asp:ScriptReference Path="/Style Library/libs/angular.min.js"></asp:ScriptReference>
<asp:ScriptReference Path="/Style Library/libs/knockout-3.0.0.js"></asp:ScriptReference>
<asp:ScriptReference Path="/Style Library/addons/wpToggle/wpToggle-jQuery.js"></asp:ScriptReference>
<asp:ScriptReference Path="/Style Library/addons/spCharts/spjs-charts-v4.js"></asp:ScriptReference>
<asp:ScriptReference Path="/Style Library/addons/quickLaunchToggle/jQuery.LISP.quicklaunch.js"></asp:ScriptReference>
</Scripts>
</asp:ScriptManager>
我正试图替换它,而是有一个html文件(或者任何允许它工作的文件),并对该文件进行调用。例如,如果我有一个html文件,其中包含以下内容:
<html>
<head>
<title>Script Controller File</title>
<script type="text/javscript" src="/script1.js"></script>
<script type="text/javscript" src="/script2.js"></script>
<script type="text/javscript" src="/script3.js"></script>
<link href="style1.css" type="text/css" rel="stylesheet" />
<link href="style2.css" type="text/css" rel="stylesheet" />
<link href="style3.css" type="text/css" rel="stylesheet" />
</head>
</html>
我可以在sharepoint中更改:
<asp:ScriptManager id="ScriptManager" runat="server" EnablePageMethods="false" EnablePartialRendering="true" EnableScriptGlobalization="false" EnableScriptLocalization="true">
<Scripts>
something something call Script Controller File
</Scripts>
</asp:ScriptManager>
这样,我就不必总是担心编辑SharePoint页面以包含我想要的脚本,而只需要编辑Script Controller文件。这可能吗?
看起来是LABjs的完美用途:(http://labjs.com/)
包括一个Javascript文件,其中包含传递给LABjs的其他所需脚本。LAB将异步/同步加载它们,并将它们添加到页面的头部。
脚本管理器
<Scripts>
<asp:ScriptReference Path="/Style Library/libs/LAB.min.js"></asp:ScriptReference>
<asp:ScriptReference Path="/Style Library/libs/scriptLoader.js"></asp:ScriptReference>
</Scripts>
scriptLoader.js
$LAB
.script("/Style Library/libs/jquery-1.10.2.min.js").wait()
.script("/Style Library/libs/jquery-ui.min.js")
.script("https://www.google.com/jsapi").wait()
.script("/Style Library/libs/jquery.SPServices-2013.01.min.js")
.script("/Style Library/libs/angular.min.js").wait()
.script("/Style Library/libs/knockout-3.0.0.js")
.script("/Style Library/addons/wpToggle/wpToggle-jQuery.js")
.script("/Style Library/addons/spCharts/spjs-charts-v4.js")
.script("/Style Library/addons/quickLaunchToggle/jQuery.LISP.quicklaunch.js").wait();
我不能100%确定哪些脚本需要同步加载。wait()告诉LAB在加载并包含.wait()之前的所有内容之前不要再进行任何脚本请求。
您可能需要检查:http://www.html5rocks.com/en/tutorials/webcomponents/imports/
这是一种新的方式(对于不受支持的浏览器使用polyfill),允许调用包含所有资源的单个HTML文件。
相关文章:
- 使用metro-uiJS对话框调用其他文件html
- 这个关键字位于$.ajax()中,用于调用其他函数来设置url
- 如何在Javascript中创建一个调用其他函数的函数
- 我用脚本创建了一个按钮.我可以通过点击按钮调用其他函数吗?我这样做,但失败了
- 在ASP中调用HTML以调用其他脚本
- Javascript 调用其他对象方法
- 用于调用其他命令的 Windows 脚本
- 需要解析其他网页的值.首先,我需要调用其他网页并从中解析 XML 值
- jQuery调用其他事件处理程序中的事件处理程序函数
- 一个 JavaScript 函数调用其他几个函数
- Ajax 可以调用其他 Ajax 页面吗?
- 当我调用其他提交函数时,$anchorScroll正在进行第二次单击
- OOJS 调用其他方法
- Javascript 对象调用其他对象粉碎迭代器
- 如何调用“;点击“;输入类型“on input type”;文件“;通过调用其他元素的上下文
- 使用此函数在回调中调用其他函数
- 当javascript函数更改html输入文本时,我希望输入文本像调用其他JS函数一样触发事件
- 调用其他标记的onclick事件
- 如何使用javascript来调用其他类似于此代码的javascript
- 在JavaScript中调用其他选项方法