类型错误:this.$E_0.getElementsByTagName 不是函数

发布于 2024-12-09 18:52:48 字数 632 浏览 0 评论 0原文

我正在尝试在 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() 实际上做了什么?使用它和简单地使用值字典作为您的选项有什么区别?

I am attempting to create a modal dialog in sharepoint 2010, but I'm getting this error:

TypeError: this.$E_0.getElementsByTagName is not a function

my code is:

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);

using firebug, i tried simply using the url field instead of the html field and it gave no error.

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

海未深 2024-12-16 18:52:48

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>

示例代码取自博客文章 在 SharePoint 对话框中呈现 html 需要 DOM 元素而不是字符串

也与此相关,SP.UI.$create_DialogOptions() 实际上做了什么?使用它和简单地使用值字典作为选项有什么区别

当您查看 SP.UI 文件中的 SP.UI.DialogOptions “类”的定义时。 Dialog.debug.js 你会看到它是一个空的 javascript 函数。

SP.UI.DialogOptions = function() {}
SP.UI.$create_DialogOptions = function() {ULSTYE:;
    return new SP.UI.DialogOptions();
}

我的猜测是它是为了客户端诊断目的而存在的。看看这个问题:这段 Javascript 代码是做什么的?

options.html requires a HTML DOM element instead of plain HTML code:

<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>

Example code taken from the blog post 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

When you look at the definition of the SP.UI.DialogOptions "class" in the file SP.UI.Dialog.debug.js you see that its a empty javascript function.

SP.UI.DialogOptions = function() {}
SP.UI.$create_DialogOptions = function() {ULSTYE:;
    return new SP.UI.DialogOptions();
}

My guess is that it is there for client diagnostic purpose. Take a look at this SO question: What does this Javascript code do?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文