我不确定我做错了什么。 我有这个输入文本区域,我希望它只在A sharePoint站点中读取,所以我写了一个方法,通过id选择元素并使其只读,它应该很简单,但它不适合我。 这是我的方法:
function ReadOnlyRich()
{
document.getElementById("ctl00_m_g_74c26ddd_a3bd_4c7b_877d_6a60c1035973_ctl00_ctl05_ctl15_ctl00_ctl00_ctl04_ctl00_ctl00_TextField_inplacerte").readOnly = true;
}
此元素的视图源代码如下所示:
<span dir="none">
<div class='ms-rtestate-field ms-rtefield' style=''>
<div id='ctl00_m_g_74c26ddd_a3bd_4c7b_877d_6a60c1035973_ctl00_ctl05_ctl15_ctl00_ctl00_ctl04_ctl00_ctl00_TextField_inplacerte_label' style='display:none'>
Rich text editor QBIQ no & (Title)
</div>
<div class=' ms-rtestate-write ms-rteflags-0' id='ctl00_m_g_74c26ddd_a3bd_4c7b_877d_6a60c1035973_ctl00_ctl05_ctl15_ctl00_ctl00_ctl04_ctl00_ctl00_TextField_inplacerte' style='min-height:42px' aria-labelledby='ctl00_m_g_74c26ddd_a3bd_4c7b_877d_6a60c1035973_ctl00_ctl05_ctl15_ctl00_ctl00_ctl04_ctl00_ctl00_TextField_inplacerte_label' contentEditable='true' >
<div class="ExternalClass67B0DBE162C14FC89FD1116AA392C2F3">
000100 (<font color="#001965">R-U: </font><br />123456 (<font color="#001965">R-U: </font>Occupational)<br />654321 (<font color="#001965">R-U: </font>/* QBIQ document description not found in CM Tool. */)<br />
</div>
</div>
<div style="clear:both;"></div>
</div>
<span dir="ltr">
答案 0 :(得分:0)
您可以使用SPUtility插件将字段设为只读或可编辑。
<script>window.SPUtility || document.write('\x3Cscript src="/sites/siteCollection/Style%20Library/Scripts/sputility.min.js" type="text/javascript">\x3C/script>')</script>
<script type="text/javascript">
$(window).load(function () {
// to make a field read-only
SPUtility.GetSPFieldByInternalName('Internal_x0020_Name').MakeReadOnly();
// or to make it editable again
SPUtility.GetSPFieldByInternalName('Internal_x0020_Name').MakeEditable();
}); //close load
</script>