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 3 of 3
  1. #1
    New Coder
    Join Date
    May 2004
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    document.location is driving me mad.

    Basically i'm trying to get the small scrollable window to change its content on the day of the week.
    At the moment it changes the whole page to the day.html.
    So how do i get the day.html to target the Iframe it is in??


    Code:
    <html>
    
    <head>
    <meta http-equiv="Content-Type"
    content="text/html; charset=iso-8859-1">
    <title>GTF</title>
    </head>
    
    <body bgcolor="#FFFFFF">
    
    <p align="center">GTF</p>
    
    <script type="text/javascript">
    
    iens6=document.all||document.getElementById
    ns4=document.layers
    
    //specify speed of scroll (greater=faster)
    var speed=5
    
    if (iens6){
    document.write('<div id="container" style="position:relative;width:175px;height:160px;border:1px solid black;overflow:hidden">')
    document.write('<div id="content" style="position:absolute;width:170px;left:0;top:0">')
    }
    </script>
    
    <ilayer name="nscontainer" width=175 height=160 clip="0,0,175,160">
    <layer name="nscontent" width=175 height=160 visibility=hidden>
    
    <!--INSERT CONTENT HERE-->
    <script>
    <!--
    mydate=new Date()
    today=mydate.getDay()
    if (today==1)
    document.location="monday.html";
    else if (today==2)
    document.location="tuesday.html";
    else if (today==3)
    document.location="wednesday.html";
    else if (today==4)
    document.location="thursday.html";
    else if (today==5)
    document.location="friday.html";
    else if (today==6)
    document.location="saturday.html";
    else
    document.location="sunday.html";
    //-->
    </script>
    <!--END CONTENT-->
    
    </layer>
    </ilayer>
    
    <script language="JavaScript1.2">
    if (iens6)
    document.write('</div></div>')
    </script>
    
    <table width="175px"><td><p align="right">
    <a href="#" onMouseover="moveup()" onMouseout="clearTimeout(moveupvar)"><img src="up.gif" border=0></a>  <a href="#" onMouseover="movedown()" onMouseout="clearTimeout(movedownvar)"><img src="down.gif" border=0></a></p></td>
    </table>
    
    <script language="JavaScript1.2">
    if (iens6){
    var crossobj=document.getElementById? document.getElementById("content") : document.all.content
    var contentheight=crossobj.offsetHeight
    }
    else if (ns4){
    var crossobj=document.nscontainer.document.nscontent
    var contentheight=crossobj.clip.height
    }
    
    function movedown(){
    if (iens6&&parseInt(crossobj.style.top)>=(contentheight*(-1)+100))
    crossobj.style.top=parseInt(crossobj.style.top)-speed+"px"
    else if (ns4&&crossobj.top>=(contentheight*(-1)+100))
    crossobj.top-=speed
    movedownvar=setTimeout("movedown()",20)
    }
    
    function moveup(){
    if (iens6&&parseInt(crossobj.style.top)<=0)
    crossobj.style.top=parseInt(crossobj.style.top)+speed+"px"
    else if (ns4&&crossobj.top<=0)
    crossobj.top+=speed
    moveupvar=setTimeout("moveup()",20)
    
    }
    
    function getcontent_height(){
    if (iens6)
    contentheight=crossobj.offsetHeight
    else if (ns4)
    document.nscontainer.document.nscontent.visibility="show"
    }
    window.onload=getcontent_height
    </script>
    </body>
    </html>

    Thanx
    Emily
    xxx
    Last edited by Emily1511; 05-27-2004 at 03:21 PM. Reason: typing error

  • #2
    Banned
    Join Date
    Sep 2003
    Posts
    3,620
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Try: document.frames['IFRAME'].location="monday.html";

  • #3
    New Coder
    Join Date
    May 2004
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    No joy!

    Does not seem to work.
    I'm trying to use it in an ILAYER, not an IFRAME.
    I tried coding
    Code:
    document.frames['nscontent'].location="monday.html";
    but it doesn't work.

    So is it possible to target an ILAYER in that way?
    Also which of the ILAYERS is the correct target?

    Code:
    <ilayer name="nscontainer" width=175 height=160 clip="0,0,175,160">
    <layer name="nscontent" width=175 height=160 visibility=hidden>
    
    <!--INSERT CONTENT HERE-->
    <script>
    <!--
    mydate=new Date()
    today=mydate.getDay()
    if (today==1)
    document.location="monday.html";
    else if (today==2)
    document.location="tuesday.html";
    else if (today==3)
    document.location="wednesday.html";
    else if (today==4)
    document.location="thursday.html";
    else if (today==5)
    document.location="friday.html";
    else if (today==6)
    document.location="saturday.html";
    else
    document.location="sunday.html";
    //-->
    </script>
    <!--END CONTENT-->
    Ta
    Emily


  •  

    Posting Permissions

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