SharePoint 2013在整页加载后添加javascript [英] SharePoint 2013 add javascript after whole page load
问题描述
免责声明:我没有使用SharePoint2013的经验。
Disclaimer: I have no experience with SharePoint2013.
我有问题 - 我必须在整个页面加载后包含/触发一些javascript函数。我试着听DOMDocumentReady和window.load事件,但是sharepoint在这些事件之后呈现页面的其余部分。
I have problem - I must include/fire some javascript functions after the whole page has been loaded. I tried listening to DOMDocumentReady and window.load events, but sharepoint render the rest of page after those events.
我的问题是:我应该做些什么才能运行渲染整个页面后的脚本与ajax。
另外我注意到页面导航基于哈希(#)部分。显然我也必须检测那个时刻。
My question is: what I should do to be able to run script after whole page with ajax is rendered. Also I noticed that page navigation is based on hash (#) part. Obviously I must detect that moment also.
任何帮助甚至链接到文档中的右页都会很棒!
Any help or even link to right page in documentation would be great!
推荐答案
你是对的,$(document).ready()之后页面上发生了很多事情。 2013确实提供了一些选择。
You are right, MANY things happen on page after $(document).ready(). 2013 does provide a few options.
1)脚本点播:(加载一个js文件然后执行我的代码。)
1) Script on Demand: (load a js file then execute my code.)
function stuffThatRequiresSP_JS(){
//your code
}
SP.SOD.executeFunc(sp.js)
2)延迟直到加载(等待)对于一个js文件,然后运行)
2) Delay until loaded (wait for a js file, then run)
function stuffToRunAfterSP_JS(){
//your code
}
ExecuteOrDelayUntilScriptLoaded(stuffToRunAfterSP_JS, "sp.js")
3)其他东西完成后加载
3) load after other stuff finishes
function runAfterEverythingElse(){
// your code
}
_spBodyOnLoadFunctionNames.push("runAfterEverythingElse");
来源:
executeFunc: http://msdn.microsoft.com/en-us/library/ff409592(ⅴ = office.14).aspx
executeFunc: http://msdn.microsoft.com/en-us/library/ff409592(v=office.14).aspx
ExecuteOrDelayUntilScriptLoaded: http://msdn.microsoft.com/en-us/library/ff411788(v = office.14).aspx
ExecuteOrDelayUntilScriptLoaded: http://msdn.microsoft.com/en-us/library/ff411788(v=office.14).aspx
无法在_spBodyOnLoadFunctionNames上找到源代码,但我在一些地方使用它。
Cant find a source on _spBodyOnLoadFunctionNames but I am using it in a few places.
祝你好运。
这篇关于SharePoint 2013在整页加载后添加javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!