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

前端之家收集整理的这篇文章主要介绍了javascript – TypeError:this.$E_0.getElementsByTagName不是函数前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我试图在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()实际上做了什么?使用它和简单地使用值的dict作为选项有什么区别?

解决方法

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“class”的定义时,您会看到它是一个空的javascript函数.

SP.UI.Dialogoptions = function() {}
SP.UI.$create_Dialogoptions = function() {ULSTYE:;
    return new SP.UI.Dialogoptions();
}

我猜测它是出于客户诊断的目的.看看这个SO问题:What does this Javascript code do?

原文链接:https://www.f2er.com/js/149987.html

猜你在找的JavaScript相关文章