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

I need to open an external web page, say, http://google.com in a modal dialog. So if I were to do

SP.UI.ModalDialog.showModalDialog(options);

I get a modal window, however, it adds the IsDlg=1 query string parameter. In fact, Google pukes at the parameter that is appended.

share|improve this question

3 Answers 3

up vote 5 down vote accepted

What you could do is pop up an application page in a modal dialog box (using the 2010 dialog framework) that contains an iframe to your desired location. You could pass in the url the iframe should show in the querystring (make sure you encode it first, and decode it in the application page).

Beware that in 2010 you'll have the ribbon as well, so what I've done to circumvent this is follow this blog post to include another querystring param when calling your application page to hide the ribbon.

share|improve this answer
    
So you are suggesting that I pop up a modal of an application page. Then somehow change the URL that is being displayed? This way, the IsDlg=1 would no longer show up? p.s. That's my colleague's blog post :) –  Tim Gabrhel Jun 3 '11 at 13:37
1  
Nah I'm suggesting you pop up the application page, it'll append IsDlg, but you have an iframe in your app page which goes to where you want. Pass in the URL for the iframe in the querystring for the application page. Your colleague's a smart dude, that code helped me just last week :) –  James Love Jun 3 '11 at 14:46
    
Gotcha. That's a disgusting solution but it appears to be all you can do. –  Tim Gabrhel Jun 3 '11 at 15:21
    
Yeah, it is. Unfortunately the Modal Dialog framework will always append IsDlg to all URLs, as it was originally intended for use only with SharePoint Pages. –  James Love Jun 3 '11 at 19:11
    
@JamesLove: Is it possible to use the html option of the showModalDialog function to pass in the iframe HTML with the URL already embedded into it? –  Stuart Pegg Oct 6 '11 at 7:45

Following on from James's answer, the html option of showModalDialog allows you to directly send html to be rendered in the dialog.

Unfortunately it accepts an HTML DOM object rather than an HTML string, so we would have to do the following:

<script language="javascript">
    function popUp() {
        var frame = document.createElement('iframe');
        frame.setAttribute('src', 'http://tsstsst.com');
        frame.setAttribute('width', '99%');
        frame.setAttribute('height', '98%');

        var options = {
            title: 'TssTssT',
            width: 950,
            height: 600,
            html: frame
        };

        SP.UI.ModalDialog.showModalDialog(options);
    }
</script>
<button OnClick="popUp();return false;">View Stu's blog!</button>

No application page required.

share|improve this answer
    
Thanks for the answer Stuart! That's a pretty neat solution and it should come in handy for me down the road. –  Tim Gabrhel Oct 11 '11 at 13:15
    
This solution doesn't work and produces a security violation error: This content cannot be displayed in a frame To help protect the security of information you enter into this website, the publisher of this content does not allow it to be displayed in a frame. –  iOnline247 Nov 9 '11 at 15:44
    
@iOnline247: The code is fine, but the choice of website has since become problematic. Google is now explicitly forbidding this kind of usage, so I've updated it with my own iframe-friendly blog. :) –  Stuart Pegg Nov 9 '11 at 16:03
1  
Thanks for the clarification. This works as expected. :) –  iOnline247 Nov 10 '11 at 15:22

You can simply try to use something like javascript:OpenPopUpPage('http://google.com') in a link. Please note that this code is case-sensitive.

share|improve this answer
    
I didn't know that existed..However, that seems to append 'IsDlg=1' to the URL still. If you do "javascript:OpenPopUpPage('google.com',600,600);";, Google throws up at the IsDlg=1 param. –  Tim Gabrhel Mar 9 '11 at 19:49

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.