Web Analytics Made Easy -
StatCounter page open chcecker - CodingForum

Announcement

Collapse
No announcement yet.

page open chcecker

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • page open chcecker

    hi,
    i would like to refer to this thread http://www.codingforum.net/showthrea...=&threadid=470
    i modified the cool code by ACJavascript a bit. here's how it looks now:

    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1250">
    <title></title>
    </head>

    <body>
    <script language="javascript">

    function go(){
    var lg=window.open("page1.htm","GoPage")
    document.forms[0].goTrue.value="true"
    }
    function check(){

    if(document.forms[0].goTrue.value=="true"){
    self.location="index.htm"
    }else{
    alert("Please click 'GO Here' first.")
    }
    }

    </script>

    <a href="javascript:go()">GO Here</a>

    <form>
    <input type="hidden" name="goTrue">
    </form>

    <a href="javascript:check()">Click here</a>
    </body>
    </html>

    the thing i want is for the check() function to check if the visitor is on page2.htm in the GoPage window (he would have to click on page1.htm which is opened by the go() function). is it possible to at all (i assume the script above will need a grand remake)

  • #2
    Thanks for calling my script cool hehe,

    I really don't understand what your trying to say.

    You want the check() function to check if the user is on page2.html when he clicked the go() function.

    or

    You want the check() function to check if the user is on the mainpage but is on page2.html when he clicks - Click here.


    Sorry, i just don't quite understand
    CYWebmaster.com - See why we dot com!!
    ACJavascripts.com - Cut & Paste Javascripts!
    SimplyProgram.com - Personal Blog

    Comment


    • #3
      well i want the user to click on a link on page1.htm that will move him to page2.htm. so the basic thing that i want the script to do is to check if the user clicked on page1.htm and moved to page2.htm - i will change the window attributes so that there is no address bar and thanks to it the script (the check() function)would only have to chceck if the 'GoPage' window is opened and the address is different than page1.htm (or if it is easier to write if may check if the page2.htm is loaded within the 'GoPage' window).

      hope i made myself clearER now.

      cheers
      mike

      Comment


      • #4
        Okay i think this might just do it. hehehe

        This part is the page that opens page1 and page2.

        ----------

        <html>
        <head>
        <meta http-equiv="Content-Type" content="text/html; charset=windows-1250">
        <title></title>
        </head>

        <body>
        <script language="javascript">

        function go(){
        var lg=window.open("page1.html","GoPage")
        document.forms[0].goTrue.value="true"
        }
        function check(){

        if(document.forms[0].goTrue.value=="true" && document.forms[0].goTrue2.value=="true"){
        self.location="index.htm"
        }else{
        alert("Please click 'GO Here' first.")
        }
        }

        </script>

        <a href="javascript:go()">GO Here</a>

        <form>
        <input type="hidden" name="goTrue">
        <input type="hidden" name="goTrue2">
        </form>

        <a href="javascript:check()">Click here</a>
        </body>
        </html>
        ----------------------


        Now put this in on page1 in the head

        ---------------------
        <script language="javascript">

        function go(){

        window.opener.document.forms[0].goTrue2.value="true"
        location.href="page2.html"
        }
        </script>
        -----------------------

        Put this in the body for the link to page2

        -----------------

        <a href="javascript:go()">Click Here</a>

        -----------------

        What happens is this.

        when you click on - Go Here -
        it puts true to the goTrue hidden textbox(as we all know)
        it then opens page1.
        When you click on the page1 link it writes to goTrue2 and opens into page2. Now If you were to go back to the main page, and tried to click the click here link it wouldn't work unless you've gone through the page1 & page2.

        I hope this works for ya
        CYWebmaster.com - See why we dot com!!
        ACJavascripts.com - Cut & Paste Javascripts!
        SimplyProgram.com - Personal Blog

        Comment


        • #5
          simplest version:

          var lg = null;
          function go(){
          lg=window.open("page1.htm","GoPage")
          }
          function check(){

          if (lg && !lg.closed && lg.location.href.indexOf("/page2.htm")!=-1){
          location.href="index.htm";
          }else{
          alert("Please click 'GO Here' first.");
          }
          }

          </script>
          </head>
          <body>
          <a href="javascript:go()">GO Here</a>
          <a href="javascript:check()">Click here</a>
          </body>
          </html>
          Glenn
          vBulletin Mods That Rock!

          Comment


          • #6
            ok i love you people this is the best forum out there!!!

            ACJavascript your code is still cool, but today i have a problem based on what glenngv wrote above (his script is also cool and shorter).

            the script doesn't work when the addresses are full (i mean page1 & 2 are located on different servers than the main file with the script - don't ask i just had to do it like that: http://www.republika.pl/~twilight218/page1.htm and http://strony.wp.pl/wp/twilight218/page2.htm [at the moment the links are empty but they're gonna look like that] )

            when i replace page1.htm and/or page2.htm with the full addresses something goes wrong and i get a message 'error on page' whuch say 'you're not entitled/no entitlement' (don't know how to translate it exactly, but this way or the other it just doesn't work)

            maybe you guys could do something about this (i hope & i believe )

            Comment


            • #7
              as i'm reading this now, i'm stumped. hehehe

              If i come up with anything i post it. I hope Glen though has something up his/her sleeve
              CYWebmaster.com - See why we dot com!!
              ACJavascripts.com - Cut & Paste Javascripts!
              SimplyProgram.com - Personal Blog

              Comment


              • #8
                i'm repeating myself now (and i'm not an expert in js), but i think that maybe it will be easier if the script (the check() function)would only have to check if the 'GoPage' window is opened and the address is different than http://www.republika.pl/~twilight218/page1.htm

                maybe now somebody could help (of course if there is anybody out there capable of rewriting the glenngv code so that it works with full addresses i would appreciate it. MUCH)

                Comment


                • #9
                  Glennv has the best idea here at the momment so, try this. Its bassed totaly of his script. Just add the full addy.

                  var lg = null;
                  function go(){
                  lg=window.open("page1.htm","GoPage")
                  }
                  function check(){

                  if (lg && !lg.closed && lg.location.href=="PutAddyHere"){
                  location.href="index.htm";
                  }else{
                  alert("Please click 'GO Here' first.");
                  }
                  }

                  </script>
                  </head>
                  <body>
                  <a href="javascript:go()">GO Here</a>
                  <a href="javascript:check()">Click here</a>
                  </body>
                  </html>

                  Hope this works
                  CYWebmaster.com - See why we dot com!!
                  ACJavascripts.com - Cut & Paste Javascripts!
                  SimplyProgram.com - Personal Blog

                  Comment


                  • #10
                    this still doesn't work everytime i give it a try with the full address i get an error in the line: if (lg && !lg.closed && lg.location.href=="http://strony.wp.pl/wp/twilight218/page2.htm"){ at column 1

                    'you're not entitled/no entitlement' - what does it mean

                    plz HEEEEEELP

                    Comment


                    • #11
                      OKay, well, I think checking for the location might not be the way to go. So I've put this together its like the first one i did with the hidden fields. It should work hehehe, but we all know how should never does. LOL.


                      -----------

                      <!doctype html public "-//w3c//dtd html 3.2//en">
                      <htmt>
                      <head>
                      <title>Windows</title>

                      <script language="javascript">

                      var url="page2.html"
                      function go(){

                      window.open(url,"page2")
                      document.forms[0].goTrue.value="true"
                      document.forms[0].goLoc.value=url
                      }
                      function check(){

                      if(document.forms[0].goTrue.value=="true" && document.forms[0].goLoc.value==url){
                      location.href="index.htm"
                      }else{
                      alert("Please Click - Go Here - First")
                      }

                      }
                      </script>
                      </head>
                      <body>

                      <form>
                      <input type="hidden" name="goTrue">
                      <input type="hidden" name="goLoc">
                      </form>

                      <a href="javascript:go()">Go Here</a>
                      <BR><BR>
                      <a href="javascript:check()">Click Here</a>

                      </body>
                      </html>

                      ---------------
                      CYWebmaster.com - See why we dot com!!
                      ACJavascripts.com - Cut & Paste Javascripts!
                      SimplyProgram.com - Personal Blog

                      Comment


                      • #12
                        'should never does' - that's good (that sould be a Murphy law - if it's not already)

                        well as you predicted it doesn't work the go() function puts document.forms[0].goTrue.value="true"
                        document.forms[0].goLoc.value=url
                        so after you click 'Go Here' you can immediately click on 'Click Here' without having to do anything in the newly open window (the user doesn't have to move from page1.htm to page2.htm - and that's what i'm trying to get here - the necessity of going from page1.htm to page2.htm)

                        i also tried the previous script you wrote (the one before the glenngv post) and it doesn't do the trick either.

                        another thing i tried was changing everything so that the code was frame-based (i used an iframe) and surprise surprise - it didn't work.

                        is it possible to make this work at all? (because i'm starting to loose faith)

                        Comment


                        • #13
                          NEVER EVER GIVE UP FAITH
                          There is always a way.

                          Okay this should work(But it never does hehehe)

                          Just follow my instructions on how to install it.

                          -----------------------------
                          This page links to page1
                          When the user clicks the Go here they can't go there
                          So when the click - Click Here - true gets placed within the hidden form.
                          Now if they try to click - Go Here - now they still can't get in.
                          -----------------------------
                          <!doctype html public "-//w3c//dtd html 3.2//en">
                          <htmt>
                          <head>
                          <title>Windows</title>

                          <script language="javascript">
                          var url="page1.html"
                          function go(){

                          window.open(url,"page1")
                          document.forms[0].goTrue.value="true"
                          }
                          function check(){

                          if(document.forms[0].goTrue.value=="true" && document.forms[0].goLoc.value==url){
                          location.href="index.htm"
                          }else{
                          alert("Please Click - Go Here - First")
                          }

                          }
                          </script>
                          </head>
                          <body>

                          <form>
                          <input type="hidden" name="goTrue">
                          <input type="hidden" name="goLoc">
                          </form>

                          <a href="javascript:go()">Go Here</a>
                          <BR><BR>
                          <a href="javascript:check()">Click Here</a>

                          </body>
                          </html>

                          -------------------------------------------
                          Save this as page1.html, This page is the one that will link to page2.html
                          When the user clicks the link the - page2.html - is put within the goLoc hidden form on the first page. If the user go's back to the first page and clicks - Go Here - they will get in. This essentaily proves that they went to page1 & page2
                          ----------------------------------------------

                          <title>Page 2</title>
                          <script language="javascript">

                          var url="page2.html"

                          function go(){
                          window.opener.document.forms[0].goLoc.value=url
                          }

                          </script>
                          </head>
                          <body>

                          <a href="javascript:go()">Click Here</a>

                          </body>
                          </html>


                          ------------------------------


                          remeber never give up.
                          CYWebmaster.com - See why we dot com!!
                          ACJavascripts.com - Cut & Paste Javascripts!
                          SimplyProgram.com - Personal Blog

                          Comment


                          • #14
                            dont' use full url

                            don't use full url of page2.htm, that is why i used indexOf instead of comparing href to full url.

                            So use this code as it is:

                            var lg = null;
                            function go(){
                            lg=window.open("page1.htm","GoPage")
                            }
                            function check(){

                            if (lg && !lg.closed && lg.location.href.indexOf("/page2.htm")!=-1){
                            location.href="index.htm";
                            }else{
                            alert("Please click 'GO Here' first.");
                            }
                            }

                            </script>
                            </head>
                            <body>
                            <a href="javascript:go()">GO Here</a>
                            <a href="javascript:check()">Click here</a>
                            </body>
                            </html>
                            Glenn
                            vBulletin Mods That Rock!

                            Comment


                            • #15
                              still nothing

                              Comment

                              Working...
                              X