Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New Coder
    Join Date
    Aug 2002
    Location
    Ipswich
    Posts
    57
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Displaying different items for different pages in a frame using an if statement?

    I am having problems getting an if statement to work. I have a page split into three frames: a menu frame (known as toc.htm), a header frame (menu.htm) and a main_window (known as fcont_login.htm). I don't want the page to display a count down clock when the main window (knwon as maintask) is fcont_login.htm. When it is any other page I want it to display the timer. I thought this would be a simple if (below) but I can't get it to work, it doesn't display the counter on any page and says there are JavaScript errors! Help is needed!!

    cheers Pete

    --the code--
    <script language="javascript">
    if (!(parent.maintask.location == fcont_login.htm))
    {
    document.write('<td valign=bottom width=16%>&nbsp;&nbsp;<font size=2><b>Auto Logoff in:</b></font></td>');
    if (document.layers)
    {
    document.write('<td valign=bottom width=12%><ilayer id="ns4timer"><layer id="ns4timer2" width=100%>&nbsp;&nbsp;</layer></ilayer></td>');
    }
    if (document.all)
    {
    document.write('<td valign=bottom><div id="timer">&nbsp;&nbsp;</div></td>');
    }
    if (document.getElementById && document.createRange)
    {
    document.write('<td valign=bottom><div id="N6timer">&nbsp;&nbsp;</div></td>');
    }
    } else
    {
    if (parent.maintask.location.href == fcont_login.htm)
    {
    document.write('<td></td>');
    }
    }
    </script>

  • #2
    Supreme Master coder! glenngv's Avatar
    Join Date
    Jun 2002
    Location
    Philippines
    Posts
    11,068
    Thanks
    0
    Thanked 256 Times in 252 Posts

    Re: Displaying different items for different pages in a frame using an if statement?

    Code:
    <script language="javascript"> 
    if (top.frames["maintask"].location.href.indexOf("fcont_login.htm")==-1)
    { 
    	document.write('<td valign=bottom width=16%>  <font size=2><b>Auto Logoff in:</b></font></td>'); 
    	if (document.layers) 
    	{ 
    		document.write('<td valign=bottom width=12%><ilayer id="ns4timer"><layer id="ns4timer2" width=100%>  </layer></ilayer></td>'); 
    	} 
    	else if (document.all) 
    	{ 
    		document.write('<td valign=bottom><div id="timer">  </div></td>'); 
    	} 
    	else if (document.getElementById && document.createRange) 
    	{ 
    		document.write('<td valign=bottom><div id="N6timer">  </div></td>'); 
    	} 
    
    } 
    else	//maintask location is fcont_login.htm 
    { 
    	document.write('<td></td>'); 
    	 
    } 
    </script>
    Glenn
    ____________________________________

    My Blog
    Tower of Hanoi Android app (FREE!)
    Tower of Hanoi Leaderboard
    Samegame Facebook App
    vBulletin Plugins
    ____________________________________


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •