admin管理员组

文章数量:1316841

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?

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?

Share Improve this question edited Oct 14, 2011 at 16:40 Stefan 14.9k4 gold badges58 silver badges63 bronze badges asked Oct 14, 2011 at 3:26 NachtNacht 3,4946 gold badges31 silver badges41 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 8

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?

本文标签: javascriptTypeError thisE0getElementsByTagName is not a functionStack Overflow