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?
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
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.
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.
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?
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(){
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?
Location: Los Angeles, CA Original Location: Philippines
Posts: 10,241
Thanks: 0
Thanked 112 Times in 111 Posts
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.
Quote:
Originally posted by ACJavascript putting this will make the window open into a new window
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.