作者热门文章
- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
我正尝试在 Sharepoint 2010 中创建模式对话框,但出现此错误:
TypeError: this.$E_0.getElementsByTagName is not a function
我的代码是:
var options = SP.UI.$create_DialogOptions();
options.html = '<div class="ExternalClass23FFBC76391C4EA5A86FC05D3D9A1904"><p>RedConnect is now available.</p></div>';
options.width = 700;
options.height = 700;
SP.UI.ModalDialog.showModalDialog(options);
使用 firebug,我尝试简单地使用 url 字段而不是 html 字段,它没有给出任何错误。
与此相关的是,SP.UI.$create_DialogOptions() 究竟做了什么?使用它和简单地为您的选项使用值的字典有什么区别?
最佳答案
options.html
需要一个 HTML DOM 元素而不是纯 HTML 代码:
<script>
function ShowDialog()
{
var htmlElement = document.createElement('p');
var helloWorldNode = document.createTextNode('Hello world!');
htmlElement.appendChild(helloWorldNode);
var options = {
html: htmlElement,
autoSize:true,
allowMaximize:true,
title: 'Test dialog',
showClose: true,
};
var dialog = SP.UI.ModalDialog.showModalDialog(options);
}
</script>
<a href="javascript:ShowDialog()">Boo</a>
示例代码取自博文 Rendering html in a SharePoint Dialog requires a DOM element and not a String .
also related to this, what does SP.UI.$create_DialogOptions() actually do? what is the difference between using it and simply using a dict of values for your options
当您查看文件 SP.UI.Dialog.debug.js 中 SP.UI.DialogOptions
“类”的定义时,您会发现它是一个空的 javascript 函数。
SP.UI.DialogOptions = function() {}
SP.UI.$create_DialogOptions = function() {ULSTYE:;
return new SP.UI.DialogOptions();
}
我的猜测是它用于客户端诊断目的。看看这个 SO 问题:What does this Javascript code do?
关于javascript - TypeError : this. $E_0.getElementsByTagName 不是函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7762736/
我是一名优秀的程序员,十分优秀!