Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

http://msdn.microsoft.com/en-us/library/ff410058.aspx says that you can use the option html to display html text in a modal.

I have a string like this;

var html = '<div><strong>Test</strong> test</div>';

Passing this in as the html option causes the error:

Microsoft JScript runtime error: Object doesn't support property or method 'getElementsByTagName'

So you can't pass a string into the html element. How can I convert my string into a format that the html option likes?

The string is being dynamically created on the sever and is being retrived via a WCF REST web service

share|improve this question
add comment

2 Answers

Here is a full example using jQuery : http://www.wawawum.com/blog/post/SharePoint-Modal-Dialog-from-HTML.aspx

share|improve this answer
1  
We require relevant answers and disclosure of any affiliation with products or websites. Please see May I promote products or websites I am affiliated with here? for guidelines. In addition, we prefer inclusion of the essential parts of the answer here, and to provide the link for reference - see how to answer for general guidelines. –  SPDoctor Sep 21 '12 at 12:17
add comment
up vote 13 down vote accepted

May not be the best wat but it works:

var test = "<div id='correspondence'>" + result + "</div>";
        $('body').append(test);

        SP.UI.ModalDialog.showModalDialog({
            html: document.getElementById(''correspondence''),
            title: "Correspondence",
            allowMaximize: false,
            showClose: true,
            autoSize: true
        });
share|improve this answer
3  
Exactly. There is a mistake in msdn, and they are not even going to fix it. html is not a string, this is a DOM element. You can find evidence in comments to msdn article. Now I always read comments in msdn :). –  Kai Jan 20 '12 at 12:16
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.