0
我正在为SharePoint 2013构建一个图像卷标器,并且出现此错误指向此行并且我不确定原因。我在学习html/js,所以我非常感谢所有的帮助。ReferenceError:未定义网站
这是代码返回错误
var oList = website.get_lists().getByTitle(bannerListName);
还有更多它的路线,但是这是什么阻止它。
(function()
{
/********************* User Defined Variables ***************************************
**** Update the variables below to customize how the banner rotator works ***********/
var bannerListName = "Banner Rotator"; //the name of the list to pull the banner items from
var interval = 7; //time to wait before showing the next picture (in seconds)
var showPages = false; //change to false if you do not want to show the page numbers
//if you know how to write CAML you can update this string
//by default it looks for all items in the list, but you can change that here
var query = '<View><Query><Where><Geq><FieldRef Name=\'ID\'/><Value Type=\'Number\'>1</Value></Geq></Where></Query><RowLimit>10</RowLimit></View>';
/***********************************************************************************/
//global variables
var index = 0;
var bannerList = [];
$(document).ready(function()
{
// make sure the SharePoint script file 'sp.js' is loaded before code runs
SP.SOD.executeFunc('sp.js', 'SP.ClientContext',start);
});
function start()
{
ctx = SP.ClientContext.get_current();
this.site = ctx.get_site();
this.website = ctx.get_web();
var oList = website.get_lists().getByTitle(bannerListName);
var camlQuery = new SP.CamlQuery();
camlQuery.set_viewXml(query);
this.collListItem = oList.getItems(camlQuery);
ctx.load(collListItem);
this.ctx.executeQueryAsync(onQuerySucceeded, onQueryFailed);
}
或者,有时我也喜欢简单地创建一个变量,再利用相同的名称。 'var website = this.website = ctx.get_web();'以便稍后在相同的环境中也可以使用'website'。 –
这回答了我的问题:)但带来了我的错误。我会尽力解决这些问题,现在我明白了发生了什么!谢谢 – user6174153