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?
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.
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
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.
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.
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
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()
Location: Los Angeles, CA Original Location: Philippines
Thanked 112 Times in 111 Posts
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.