Opening web pages inside a div in asp.net

不问归期 提交于 2019-12-13 22:39:11

问题


I have a requirement of just surfing through the net in my asp application and for that purpose i dropped an iframe.

But after that i found that certain sites likes google,fb,youtube etc wont open up in iframe due to security concerns.

After some discussions with my colleagues, i thought of a solution of displaying the web page(just like iframe) in a div and then displaying that div in a modal pop up,in which the user can navigate to any pages within that modal pop up

But after some initial searching ,i havent found anything where i can start towards my aim.So, i thought of asking it here.

Can anyone guide me to a proper direction to help me achieve my aim.Any help will be appreciated.

Thanks


回答1:


Look at this example:

$('#btnShowModal').click(function () {
            $.post
            (
                'MyController',
                {
                    some parameters to pass
                },
                function (htmlResult) {
                    $('#dialogWindowContent').html('');
                    $('#dialogWindow').dialog(
                    {
                        title: 'Title',
                        autoopen: true,
                        width: 'auto',
                        //height: 180,
                        resizable: false,
                        modal: true,
                        draggable: false
                    });
                    $(window).resize(function () {
                        $("#dialogWindow").dialog("option", "position", "center");
                    });
                    //position of modalWindow will always be in center of your browser window

                    $('#dialogWindowContent').append(htmlResult);
                    $("#dialogWindow").dialog("option", "position", "center");
                });
            return false;
        });

It's my button and div to modal window:

<input type="button" value="Add theme" id="btnShowModal" />
<div id="dialogWindow">
    <div id="dialogWindowContent">
    </div>
</div>

I wrote it to my MVC application. And as understand, you should only rewrite post-method. As htmlResult you can return any html code and it will be shown in your modal window.

I hope, it will be usefull for you.



来源:https://stackoverflow.com/questions/13817432/opening-web-pages-inside-a-div-in-asp-net

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!