Click here to Skip to main content
15,885,782 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi, I'm using Asp.net, I have a main page containing 2 iFrames.
First iFrame is like a menu where each item is a link(a href).
Second frame is to display the aspx page corresponding to the clicked item.

I successfully updated the second frame source on click of href items while using IE and Chrome browsers, but the problem is that nothing is happening on click event using Firefox 24.0 browser, I tried more than one method to make it work, but nothing worked.
Please help.

Main Page code:
ASP.NET
<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">
<table style="height:99%;width:100%">
    <tr>
        <td style="height:100%;width:18%">
            <iframe seamless src="HelpMenu.aspx" style="height: 99%; width: 99%;overflow:hidden;"></iframe>
        </td>
        <td style="height:100%;width:82%">
            <iframe id="contentFrame" seamless src="Introduction.aspx" style="height: 99%; width: 99%;overflow:hidden;border-right:none hidden;"></iframe>
        </td>
    </tr>
</table>
</asp:Content>


code of function i used to change frame source:

ASP.NET
    <asp:Content ID="AfterScript" ContentPlaceHolderID="ContentAfterScript" runat="server">
    <script type="text/javascript">
        $(window).ready(function () {
            $("a.x-tree-node-anchor").click(function (event) {
                event.preventDefault();

                var pageUrl = this.text + '.aspx'
                pageUrl = pageUrl.replace(' ', '')

                loadIframe('contentFrame', pageUrl);
            });

            function loadIframe(iframeName, url) {
                var $iframe = $('#' + iframeName);

                $iframe.attr('src', url);
                top.frames["contentFrame"].location = url;

                //The document.getElementById method returns an error that this is an undefined object, which is really weird !!
                //document.getElementById('contentFrame').setAttribute('src', url);
                //document.getElementById(iframeName).contentWindow.location.reload(true);
                return false;
            }
        });
    </script>
    </asp:Content>
Posted

1 solution

use this
-------------


$('#'+iframeName).attr("src",url)
 
Share this answer
 
Comments
saleem_deek 30-Oct-13 3:03am    
Thx a lot, and I thought it's always better to assign objects in vars !! hehe

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900