gpt4 book ai didi

javascript - TypeError : this. $E_0.getElementsByTagName 不是函数

转载 作者:数据小太阳 更新时间:2023-10-29 05:13:33 24 4
gpt4 key购买 nike

我正尝试在 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.jsSP.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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com