Web Analytics Made Easy -
StatCounter Go here or there? It depends - CodingForum

Announcement

Collapse
No announcement yet.

Go here or there? It depends

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

  • Go here or there? It depends

    Hi,

    I want to try to bring visitors to 2 different sites, depending on a variable. It has to work on all major browsers.

    This is the scenario:

    A visitor goes to my main page. They click a link that pops up a new window. And the url to that page depends upon whether or not they have a certain other window open. So if the visitor has that certain other window open, then the page that they opened would go to www.yahoo.com. If they don't, they go to www.excite.com instead. Can anyone come up with a script?

    A thanks goes out to all repliers

  • #2
    Is this possible anyone?

    Comment


    • #3
      it is possible,i believe as you can detect if a window is open or not via its name a believe.

      scroots
      Spammers next time you spam me consider the implications:
      (1) that you will be persuaded by me(in a legitimate mannor)
      (2)It is worthless to you, when i have finished

      Comment


      • #4
        little help

        hi!

        if it was your homepage, that opened the other sites in new windows, there will no problem. If you want to check, if the user opened a new site in a new Browser-Window by his own, it will be impossible, my opinion.

        in the case that your page opens a new window, you can check if this window has the url you are searching for.

        for example:

        your site opened Yahoo with variable in a javascript:

        var YahooWin= window.open("http://www.yahoo.com","YahooWindow","width=300,height=200");

        then you can check, if the window is still open with "Name.closed"

        if (YahooWin.closed==true) alert("Window closed");
        if (YahooWin.closed==false) alert("Window open");

        to search for the URL in this window use the following term

        var URL=YahooWin.location.href;
        alert(URL);

        this will show you, what site is opened in the window. You could use this also to check the url, with if (URL== "..... or if (URL!=.....

        to check this things it is obsolent, that you have opened the pages in new windows with the way i told you above. The opening should be done with an variable .
        Than there shouldn't be problems.

        Comment


        • #5
          Hi,

          Once again thanks for all the replies.

          I'm not sure that I explained everything so well, so I'll try to use more names.

          A visitor goes to www.myaddress.com/index.html, they click and open a new window named www.myaddress.com/login.html and login. When they go to click on a basic link on my site, they open another window named www.myaddress.com/link.html, this page should check to see that the window- www.myaddress.com/login.html is present. If it is, then www.myaddress.com/link.com will be forwarded to www.yahoo.com. If not, then it will be forwarded to www.excite.com. Can anyone kind of recap on the last script to fit the above.

          Much appreciation and thanks

          Comment


          • #6
            can this be done?

            Comment


            • #7
              Will this work for ya??

              -----------

              <script language="javascript">

              var login=window.open('login.html','loginpage')

              function search(){

              if(login.closed==true){
              window.open("http://www.yahoo.com","yahooWindow")
              }else{
              window.open("http://www.excite.com","ExciteWindow")
              }
              }

              </script>


              <a href="javascript:search()">Click here</a>
              CYWebmaster.com - See why we dot com!!
              ACJavascripts.com - Cut & Paste Javascripts!
              SimplyProgram.com - Personal Blog

              Comment


              • #8
                ALMOST done... It's great, but I don't want the login.html to load by itself. I want the user to click to open login.html. Everything else is good. Anyone able to convert it?

                You all are doing a great job

                Comment


                • #9
                  Does anyone have an idea?

                  Comment


                  • #10
                    Does this work for ya fox,
                    its a little different from the last one but it does the same.

                    If the person clicks the long link, " true " is written to the hidden textbox.

                    Then when someone clicks on another link with the search function on it, it checks to see if the hidden textbox has " true " writtin in it. If it does it opens yahoo. If it doesn't then it opens excite. So it pretty much does the same thing

                    ----------


                    <script language="javascript">

                    function login(){
                    var lg=window.open("Login.html","LoginPage")
                    document.forms[0].loginTrue.value="true"
                    }
                    function search(){

                    if(document.forms[0].loginTrue.value=="true"){
                    window.open("http://www.yahoo.com","YahooPage")
                    }else{
                    window.open("http://www.excite.com","ExcitePage")
                    }
                    }

                    </script>

                    <a href="javascript:login()">Login Here</a>

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

                    <a href="javascript:search()">Click here</a>

                    --------

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

                    Comment


                    • #11
                      Hi,

                      I tried that ACJ, but each hyperlink goes to the below, and in the same window. What happened?


                      C:\Documents and Settings\Administrator\My Documents\My Webs\myweb5\java script:search()

                      C:\Documents and Settings\Administrator\My Documents\My Webs\myweb5\java script:login()

                      If you can, try to work within this script, because i have multiple links on the same page I need to do this with, and naming needs to be easy. Maybe if you just defined login under "search()" to equal the name of the login window, instead of a variable. I don't know, I can only do so much with javascript. What do you think?

                      <script language="javascript">

                      var login=window.open('login.html','login')

                      function search(){

                      if(login.closed==true){
                      window.open("http://www.yahoo.com","yahooWindow")
                      }else{
                      window.open("http://www.excite.com","ExciteWindow")
                      }
                      }

                      </script>


                      <a href="javascript:search()">Click here</a>


                      Thanks
                      Last edited by cunning-fox; Jun 23, 2002, 10:13 PM.

                      Comment


                      • #12
                        putting this will make the window open into a new window

                        <a href="javascript:login();" target="_new">Login here</a>
                        <BR>
                        <a href="javascript:search();" target="_new">Click here</a>
                        CYWebmaster.com - See why we dot com!!
                        ACJavascripts.com - Cut & Paste Javascripts!
                        SimplyProgram.com - Personal Blog

                        Comment


                        • #13
                          correct ACJavascript, but, no offense, it seems you treat _new as a predefined target property value. Please correct me if I'm wrong with my impression. I've also seen this before in the previous post maybe in the old forum.
                          The predefined values of target are: _blank, _self, _top. Yes of course your code will work because if you provide a window/frame name that does not exist, a new window will be opened.

                          Just clarifying for the sake of all beginners.

                          Originally posted by ACJavascript
                          putting this will make the window open into a new window

                          <a href="javascript:login();" target="_new">Login here</a>
                          <BR>
                          <a href="javascript:search();" target="_new">Click here</a>
                          Glenn
                          vBulletin Mods That Rock!

                          Comment


                          • #14
                            YOUR 100% right, but they do both work the same. But I should of used the right code. hehehe

                            I hope this doesn't effect my status here hehehehehe
                            CYWebmaster.com - See why we dot com!!
                            ACJavascripts.com - Cut & Paste Javascripts!
                            SimplyProgram.com - Personal Blog

                            Comment


                            • #15
                              Hi,

                              The last code mentioned with the form did not work. I am sticking with this code below. But I need to use the first function on another page by itself, and still use the second function to check the window. Does anyone know how to correctly implement cookies to accomplish this, or is there a whole lot easier way I'm missing to do this (windows can have names, so I'm thinking why not just check the name with javascript, then let it determine where the page should go (second function) instead of creating all of these extra variables)? Can anyone come up with THE solution, so we can put this topic to rest.


                              <script language="JavaScript">
                              <!--

                              condition = '';

                              function createCondition() {

                              condition = window.open('condition.html', 'condition');
                              }

                              function condPopUp() {

                              if(condition && condition.open && ! condition.closed) {

                              success = window.open('success.html', 'success');

                              } else {

                              failure = window.open('login-required.html', 'failure');

                              }

                              }
                              //-->
                              </script>

                              Comment

                              Working...
                              X