开发者

Passing value between IFRAMES and refresh page

I need to pass multiple va开发者_JAVA技巧lues between two embedded IFRAMES and refresh the receiving iframe src, how can this be done. Preferably in c# code behind file (asp.net).

Any ideas will be good. thanks,


Here is a quick example using jQuery to sent text to a textbox/input field on a iFrame target page.

Parent Page with Embedded iFrame:

<script type="text/javascript">
    $(document).ready(function () {
        var $iframe1 = $('#iframe1').contents();
        var $iframe2 = $('#iframe2').contents();
        $iframe1.find('#testInput').val('Set on iFrame1');

        $iframe2.find('#testInput').val($iframe1.find('#testInput').val());
    });
</script>

<body>
    <form id="form1" runat="server">
    <div>
        <iframe name="iframe1" id="iframe1" src="TargetPage.htm" width="600px" height="400px"></iframe>
        <iframe name="iframe2" id="iframe2" src="TargetPage.htm" width="600px" height="400px"></iframe>

    </div>
    </form>
</body>

Target Page "TargetPage.htm"

<body>
    <input type="text" id="testInput" value="" />
</body>

NOTE: If your using asp.net, you should use $('#<%= TextBox1.ClientID %>') to access the control using the dynamic ID.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜