Click here to Skip to main content
15,921,351 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
I am using JQuery to create a website. I have used an idea "A Page in a html page" to display one page (for example home.html) in a master page(default.html).
-- Following is the code I have used for Menu in Default.html --
XML
<div id="PSMenu" class="class_MenuTab">
    <ul>
        <li><a id="mnuHome" href=""> Home </a></li>
        <li><a id="mnuTechnology" href=""> Technology </a></li>
        <li><a id="mnuMethodology" href="">Methodology</a></li>
        <li><a id="mnuServices" href="">Services</a></li>
        <li><a id="mnuAboutus" href="">About us</a></li>
        <li><a id="mnuCareers" href="">Careers</a></li>
        <li><a id="mnuContactus" href="">Contact us</a></li>
    </ul>
</div>


-- Following is the code in Default.html for what I meant --
XML
<table id="Table_FrameContainer" cellpadding="0" cellspacing="0" border="0">
    <tr>
        <td id="tdIFrameContainer">
            <iframe id="iFrameHome" class="SubPage" src="Home.html" scrolling="no">
            </iframe>
            <iframe id="iFrameCareers" class="SubPage" src="Careers.html" scrolling="no">
            </iframe>
            <iframe id="iFrameContactUs" class="SubPage" src="ContactUs.html" scrolling="no">
            </iframe>
        </td>
    </tr>
</table>


I used this idea with the help of iframe tags in default.html page.

For the same, I have used the jquery script which identifies the frames by there IDs and hide/show them when particular menus are clicked on homepage. This means, if I click 'Contact Us' menu of default html page, it hides all iframes other than iframe containing ContactUs.html sub html page.
-- Following is the code I have put in .js file--

$(document).ready(function(){
    $("#iFrameCareers").hide();
    $("#iFrameContactUs").hide();
    
    $("#iFrameHome").show();
                
    $("#mnuHome").click(function(){
        $("#iFrameCareers").hide();
        $("#iFrameContactUs").hide();
        
        $("#iFrameHome").show();
    });
    $("#mnuCareers").click(function(){
        $("#iFrameHome").hide();
        $("#iFrameContactUs").hide();
        
        $("#iFrameCareers").show();
    });
    $("#mnuContactus").click(function(){
        $("#iFrameHome").hide();
        $("#iFrameCareers").hide();
        
        $("#iFrameContactUs").show();
    });
});

--------------------------------------------------------------------------------
Here, when I press Home menu on menu bar, it should display the iframe with id="iFrameHome" and hide iframes with id="iFrameCareers" and id="iFrameContactUs". In the same manner for all.

Currently, what I want is happening, but for very short time. Means, when we press Home menu in default page it displays iframe with id="iFrameHome" for 1 second and again start displaying all the frames together.

I want following, If the Contact Us menu is clicked, the page should focus only the iframe with id="iFrameContactUs" in Default.html page and same for all the pages.

Please help me out for this issue.
Thank you very much for help in advance.
Posted
Updated 15-Jul-11 2:02am
v3
Comments
Yuri Vital 15-Jul-11 6:46am    
What have you tried ? Post some code.

I wouldn't use this approach.

I would use the JQuery Tabs control and switch content on demand, Look at this article Google Chrome Extension - CodeProject Reputation Watcher[^]on how i achieved that, take particular note of the tab control referencing in the "Why Use JQuery UI" section.

The tab has a number of pages, some have local page content, other have externally referenced files.

This would take care of your needs I think, simply and effectively.
 
Share this answer
 
Why use iFrames at all? You can use ajax to load the contents from other pages.

<div id="PSMenu" class="class_MenuTab">
    <ul>
        <li><span>Home</span></li>
        <li><span>Technology</span></li>
        <li><span>Methodology</span></li>
        <li><span>Services</span></li>
        <li><span>About us</span></li>
        <li><span onclick="ShowCareers">Careers</span></li>
        <li><span>Contact us</span></li>
    </ul>
</div>

<div id="careers" />
<div id="contactus" />


PHP
function ShowCareers()
{
$.get("careers.html", function(data) {
  $("careers").html(data);
});
}


http://api.jquery.com/jQuery.get/[^]
 
Share this answer
 
Hello,

Off course their are setting inside the javascript file that enables you to keep the iframe for a time longer than one second.Please try to see what settings are available and change them to fit your needs.

Good luck !
 
Share this answer
 

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