仅在页面加载时执行Javascript,而不是PostBack(SharePoint) [英] Execute Javascript only on page load, not PostBack (SharePoint)

查看:109
本文介绍了仅在页面加载时执行Javascript,而不是PostBack(SharePoint)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在SharePoint网站上的自定义页面上执行页面加载上的一些JavaScript(它使用当前用户填充人员选择器)。问题是代码也在回发上执行,我不想要,因为它会重置对人员选择器的任何更改。

I'm trying to execute some JavaScript on page load on a custom page on a SharePoint site (it populates the people picker with the current user). The problem is that the code executes on postback too, which I don't want as it will reset any changes to the people picker.

我尝试过使用 if(!IsPostBack)无济于事。这一切都出错了,给出了

I've tried using if(!IsPostBack) to no avail. Everything errors out at that point, giving


SCRIPT5009:'IsPostBack'未定义。

SCRIPT5009: 'IsPostBack' is undefined.

我在网上找不到任何帮助。有任何想法吗?谢谢

I can't find anything online to help with this. Any ideas? Thanks

推荐答案


您可以创建这样的函数:

You can create a function like this:



function IsPostBack() {
    var ret = '<%= Page.IsPostBack%>' == 'True';
    return ret;
}

这篇关于仅在页面加载时执行Javascript,而不是PostBack(SharePoint)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆