What is the onload event handler needed to get # assigned to parent variable?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tpgames
    Contributor
    • Jan 2007
    • 783

    What is the onload event handler needed to get # assigned to parent variable?

    What is the onload event handler needed to get # assigned to parent variable? What I tried didn't work!
    Code is from JS bible, page 127-8 with some minor alterations by me.
    Parent Page (in part)
    Code:
    <!-- start
    function goNext() {
    var currOffset = parseInt(parent.currTitle);
    if (currOffset < 40) {
    	currOffset +=1;
    	parent.cryptogram.location.href = "http://www.tpgames.net/gaming/2/word/cipher/f/c/c" + currOffset + ".html";
    	parent.keycode.location.href = "http://www.tpgames.net/gaming/2/word/cipher/f/z/z" + currOffset + ".html";
    } else {
    	alert("This is the last Cryptogram under this Image Theme.");
    	}
    }
    funtion goPrev() {
    	var currOffset = parseInt(parent.currTitle);
    	if (currOffset > 1) {
    		currOffset -= 1;
    		parent.cryptogram.location.href = "/gaming/2/word/cipher/f/c/c" + currOffset + ".html";
    		parent.keycode.location.href = "/gaming/2/word/cipher/f/z/z" + currOffset + ".html";
    } else {
    	alert("This is the first Cryptogram under this Image Theme.");
    	}
    }
    // end -->
    </script>
    
    </head>
    
    <body>
    
    <div id="bgHolder">
    </div>
    
    
    <iframe name="cryptogram" frameborder="1" height="50" scrolling="auto" width="800" 
    src = "http://www.tpgames.net/gaming/2/word/cipher/f/c/c1.html">
    </iframe>
    
    <iframe name="keycode" frameborder="1" height="60" scrolling="auto" width="800" 
    src = "http://www.tpgames.net/gaming/2/word/cipher/f/z/z1.html">
    </iframe>
    
    
    <tr>
    <td>
    
    <a href="javascript:goPrev()">
    <img src="http://www.tpgames.net/gaming/2/word/cipher/f/goprev.gif">
    </a>
    ||
    
    <a href="javascript:goNext()">
    <img src="http://www.tpgames.net/gaming/2/word/cipher/f/gonext.gif">
    </a>
    The page that needs an onload event handler: Taken from c1
    Code:
    <body onload="currTitle()">
    <table>
    <tr><td class="tpmarble">
    WMS KZLZECB RM YSPL RFC RMZQR.
    </table>
    The onload = bit didn't work. I don't want the next page in the frame to come up until the user clicks on goNext. When I click on goNext, nothing happens.
    Thanks!

    The Parent Page
    page c1
    page z1
    page c2
    page z2
  • tpgames
    Contributor
    • Jan 2007
    • 783

    #2
    Using
    Code:
    <body onload="goNext(); goPrev()">
    didn't work either! Still nothing happened.

    Comment

    • tpgames
      Contributor
      • Jan 2007
      • 783

      #3
      Lastly, I tried this:
      Code:
      <body onload="parent.currTitle.location='/gaming/2/word/cipher/f/2.html'">
      Any questions, I'll post an answer in 10 hours or so.

      Comment

      • tpgames
        Contributor
        • Jan 2007
        • 783

        #4
        I've been trying to research and find an answer, but not understanding what I've read yet. And, no one has had the time yet to read this. So, will check back on Friday.

        Comment

        • acoder
          Recognized Expert MVP
          • Nov 2006
          • 16032

          #5
          Change the src of the iframe.

          Comment

          • tpgames
            Contributor
            • Jan 2007
            • 783

            #6
            Originally posted by acoder
            Change the src of the iframe.
            Excuse the denseness of my brain, but what would I change the src too?
            Changing the body onload url to c1.html gives me the alert boxes but doesn't give me c2.html.
            Code:
            body onload="parent.currTitle.location='/gaming/2/word/cipher/f/c/c1.html'">
            If I change it to c2.html, then the user doesn't get to do c1.html first. If I change it to 3.html, one doesn't get the correct page at all. The currOffset is suppose to be the page number the
            Code:
            ...cipher/f/c/c" + currOffset + ".html";
            and is suppose to give me the url folders + file name c + number attached to file name + .html.
            Thanks!

            Comment

            • tpgames
              Contributor
              • Jan 2007
              • 783

              #7
              I was changing the onload event handler in the 2.html doc.
              Changing the onload event handler on c1 and c2 to
              Code:
              <body onload="parent.currTitle.location='/gaming/2/word/cipher/f/c/c1.html'">
              Or having the link be to 2.html didn't work.

              Comment

              • tpgames
                Contributor
                • Jan 2007
                • 783

                #8
                Code:
                <iframe name="cryptogram" frameborder="1" height="50" scrolling="auto" width="800" 
                src = "http://www.tpgames.net/gaming/2/word/cipher/f/c/c1.html">
                </iframe>
                
                <iframe name="keycode" frameborder="1" height="60" scrolling="auto" width="800" 
                src = "http://www.tpgames.net/gaming/2/word/cipher/f/z/z1.html">
                </iframe>
                The iframe links are to the exact page that the user should see first. I don't understand what they should link too. I'm suppose to be able to change the frame content without having to change the entire page.
                Thanks!

                Comment

                • tpgames
                  Contributor
                  • Jan 2007
                  • 783

                  #9
                  The Current Set up of the pages:
                  2.html
                  Code:
                  <script type="text/javascript">
                  <!-- start
                  function goNext() {
                  var currOffset = parseInt(parent.currTitle);
                  if (currOffset < 40) {
                  	currOffset +=1;
                  	parent.cryptogram.location.href = "http://www.tpgames.net/gaming/2/word/cipher/f/c/c" + currOffset + ".html";
                  	parent.keycode.location.href = "http://www.tpgames.net/gaming/2/word/cipher/f/z/z" + currOffset + ".html";
                  } else {
                  	alert("This is the last Cryptogram under this Image Theme.");
                  	}
                  }
                  function goPrev() {
                  	var currOffset = parseInt(parent.currTitle);
                  	if (currOffset > 1) {
                  		currOffset -= 1;
                  		parent.cryptogram.location.href = "http://www.tpgames.net/gaming/2/word/cipher/f/c/c" + currOffset + ".html";
                  		parent.keycode.location.href = "http://www.tpgames.net/gaming/2/word/cipher/f/z/z" + currOffset + ".html";
                  } else {
                  	alert("This is the first Cryptogram under this Image Theme.");
                  	}
                  }
                  // end -->
                  </script>
                  
                  </head>
                  
                  <style>
                  
                  #bgHolder {height:389px; width:494px; display:block; overflow:hidden;}
                  
                  </style>
                  
                  
                  
                  <!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
                  
                  <!-- BODY ONLOAD CATASTROPHE -->
                  
                  
                  <body onload="parent.currTitle.location='http://www.tpgames.net/gaming/2/word/cipher/f/c/c1.html'">
                  
                  
                  <div id="bgHolder">
                  
                  </div>
                  
                  <!-- %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -->
                  <!-- NOTE: Iframe! -->
                  
                  
                  
                  
                  <table>
                  <tr>
                  <td class="tpmarble" colspan="3">
                  
                  <iframe name="cryptogram" frameborder="1" height="50" scrolling="auto" width="800" 
                  src = "http://www.tpgames.net/gaming/2/word/cipher/f/c/c2.html">
                  </iframe>
                  
                  
                  <tr>
                  <td class="tpmarble" colspan="3">
                  
                  <iframe name="keycode" frameborder="1" height="60" scrolling="auto" width="800" 
                  src = "http://www.tpgames.net/gaming/2/word/cipher/f/z/z2.html">
                  </iframe>
                  
                  
                  <tr>
                  <td class="tpmarble" colspan="3">
                  <a href="http://www.tpgames.net/gaming/2/word/cipher.html">
                  Cryptology Nav </a>
                  
                  &nbsp; &nbsp; || &nbsp; &nbsp;
                  
                  <a href="javascript:goPrev()">
                  <img src="http://www.tpgames.net/gaming/2/word/cipher/f/goprev.gif">
                  </a>
                  
                  &nbsp; &nbsp; || &nbsp; &nbsp;
                  
                  <a href="javascript:goNext()">
                  <img src="http://www.tpgames.net/gaming/2/word/cipher/f/gonext.gif">
                  </a>
                  I used the following body onload tags in c1 and c2.
                  Body onload tag 1 with c1 content:
                  Code:
                  <body onload="parent.currTitle.location='/gaming/2/word/cipher/f/c/c1.html'">
                  
                  <table>
                  <tr><td class="tpmarble">
                  
                  WMS KZLZECB RM YSPL RFC RMZQR.

                  Body onload trial 2 with c2 content:
                  Code:
                  <body onload="parent.currTitle.location='/gaming/2/word/cipher/f/2.html'">
                  <table>
                  <tr><td class="tpmarble">
                  DEQD GQS BKD DEFJF LN CLOEDLSO CBJ NBGFDELSO EF XFVLFYFN LS, VLAF HBJVP ZFQIF!
                  The errors I receive:
                  This is the first cryptogram under this theme.
                  This is the last cryptogram under this theme.
                  But, I never get page c2 and z2 (the helper file) to load.
                  Thanks!

                  Comment

                  • tpgames
                    Contributor
                    • Jan 2007
                    • 783

                    #10
                    Happy Easter! Now that everyone is full on celebrations, is there anyone online for JS help?
                    Thanks!
                    Bump...

                    Comment

                    • tpgames
                      Contributor
                      • Jan 2007
                      • 783

                      #11
                      Originally posted by tpgames
                      Code:
                      <iframe name="cryptogram" frameborder="1" height="50" scrolling="auto" width="800" 
                      src = "http://www.tpgames.net/gaming/2/word/cipher/f/c/c1.html">
                      </iframe>
                      
                      <iframe name="keycode" frameborder="1" height="60" scrolling="auto" width="800" 
                      src = "http://www.tpgames.net/gaming/2/word/cipher/f/z/z1.html">
                      </iframe>
                      The iframe links are to the exact page that the user should see first. I don't understand what they should link too. I'm suppose to be able to change the frame content without having to change the entire page.
                      Thanks!
                      Anyone have any clues? I appreciate the answer "change the src of the iFrame" but I don't understand what I'm suppose to change it too.
                      Thanks!

                      Comment

                      • acoder
                        Recognized Expert MVP
                        • Nov 2006
                        • 16032

                        #12
                        For accessing iframes, see link.

                        You have not defined goNext() properly, hence the errors. You can't parse the iframe object and get a number.

                        Comment

                        • tpgames
                          Contributor
                          • Jan 2007
                          • 783

                          #13
                          Sorry, but I've read and reread that page several times, did lots of research and didn't understand it. Why I've not posted back until now. He is not trying to get 2 frames to move using only 1 button. I have yet to understand anything at the quirksmode site. It not them, its me.

                          According to the JavaScript bible, one can indeed have 2 frames that change their content according to 1 link. Most of the code originated from that book. However, I can NOT figure out how to change their code to my purposes. I am ready to give up!
                          No one on the web even does what I am attempting to do! I am going to attempt to email the author and see if he can figure out what the beep I am doing wrong! He has a 'help file' that loads on the bottom frame, and a 'normal page' that loads in the top frame, and the navigation frame on the left. Which is where my code is different. I don't have navigation on the left, it on the very bottom. Plus, I have a rotating image thingy on the top left. I'm just trying to get the code to move 2 frames forward 1 notch with each click of the button. If I were to use a link array, how would one get the contents of that link to show up? showArray doesn't work. BuildArray won't work.
                          It would probably be easier if I were to just learn how to write the silly cipher game in JS to begin with, instead of trying to use HTML and only use JS to move the silly pages in the frames. Then again maybe not, as I am a complete idiot when it comes to understanding JavaScript!
                          Sorry for rambling. I've had a headache for 4 days and trying to understand this at the same time. Not working. Thanks.

                          Comment

                          • tpgames
                            Contributor
                            • Jan 2007
                            • 783

                            #14
                            I found a different code that works better. I'm just going to have the z1 page in a frame on the c1page. They will have to click on a series of links they want. I'm just not getting JavaScript yet and link structure and all. :>)

                            Thanks for trying to help me!
                            This case closed.

                            Comment

                            Working...