Go Back   CodingForums.com > :: Client side development > JavaScript programming

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 06-21-2002, 05:15 AM   PM User | #1
cunning-fox
New Coder

 
Join Date: Jun 2002
Posts: 58
Thanks: 0
Thanked 0 Times in 0 Posts
cunning-fox is an unknown quantity at this point
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
cunning-fox is offline   Reply With Quote
Old 06-21-2002, 05:33 PM   PM User | #2
cunning-fox
New Coder

 
Join Date: Jun 2002
Posts: 58
Thanks: 0
Thanked 0 Times in 0 Posts
cunning-fox is an unknown quantity at this point
Is this possible anyone?
cunning-fox is offline   Reply With Quote
Old 06-21-2002, 06:34 PM   PM User | #3
scroots
Senior Coder

 
Join Date: Jun 2002
Location: UK
Posts: 1,137
Thanks: 0
Thanked 0 Times in 0 Posts
scroots is an unknown quantity at this point
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
scroots is offline   Reply With Quote
Old 06-21-2002, 06:43 PM   PM User | #4
foss
New to the CF scene

 
Join Date: Jun 2002
Location: Graz (Austria)
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
foss is an unknown quantity at this point
Lightbulb 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.
foss is offline   Reply With Quote
Old 06-22-2002, 02:20 AM   PM User | #5
cunning-fox
New Coder

 
Join Date: Jun 2002
Posts: 58
Thanks: 0
Thanked 0 Times in 0 Posts
cunning-fox is an unknown quantity at this point
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
cunning-fox is offline   Reply With Quote
Old 06-22-2002, 06:09 PM   PM User | #6
cunning-fox
New Coder

 
Join Date: Jun 2002
Posts: 58
Thanks: 0
Thanked 0 Times in 0 Posts
cunning-fox is an unknown quantity at this point
can this be done?
cunning-fox is offline   Reply With Quote
Old 06-22-2002, 11:59 PM   PM User | #7
ACJavascript
Regular Coder

 
Join Date: Jun 2002
Location: FL, USA
Posts: 734
Thanks: 0
Thanked 0 Times in 0 Posts
ACJavascript is on a distinguished road
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
ACJavascript is offline   Reply With Quote
Old 06-23-2002, 05:32 AM   PM User | #8
cunning-fox
New Coder

 
Join Date: Jun 2002
Posts: 58
Thanks: 0
Thanked 0 Times in 0 Posts
cunning-fox is an unknown quantity at this point
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
cunning-fox is offline   Reply With Quote
Old 06-24-2002, 01:15 AM   PM User | #9
cunning-fox
New Coder

 
Join Date: Jun 2002
Posts: 58
Thanks: 0
Thanked 0 Times in 0 Posts
cunning-fox is an unknown quantity at this point
Does anyone have an idea?
cunning-fox is offline   Reply With Quote
Old 06-24-2002, 01:32 AM   PM User | #10
ACJavascript
Regular Coder

 
Join Date: Jun 2002
Location: FL, USA
Posts: 734
Thanks: 0
Thanked 0 Times in 0 Posts
ACJavascript is on a distinguished road
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
ACJavascript is offline   Reply With Quote
Old 06-24-2002, 03:06 AM   PM User | #11
cunning-fox
New Coder

 
Join Date: Jun 2002
Posts: 58
Thanks: 0
Thanked 0 Times in 0 Posts
cunning-fox is an unknown quantity at this point
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; 06-24-2002 at 03:13 AM..
cunning-fox is offline   Reply With Quote
Old 06-24-2002, 03:10 AM   PM User | #12
ACJavascript
Regular Coder

 
Join Date: Jun 2002
Location: FL, USA
Posts: 734
Thanks: 0
Thanked 0 Times in 0 Posts
ACJavascript is on a distinguished road
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
ACJavascript is offline   Reply With Quote
Old 06-24-2002, 03:22 AM   PM User | #13
glenngv
Supreme Master coder!


 
glenngv's Avatar
 
Join Date: Jun 2002
Location: Los Angeles, CA Original Location: Philippines
Posts: 10,241
Thanks: 0
Thanked 112 Times in 111 Posts
glenngv will become famous soon enough
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

<a href="javascript:login();" target="_new">Login here</a>
<BR>
<a href="javascript:search();" target="_new">Click here</a>
__________________
Glenn
_____________________________________________
Play Tower of Hanoi Android app (Ad-FREE!)
Play Tower of Hanoi Android app (FREE!)
Go to Tower of Hanoi Leaderboard
Play Tower of Hanoi Facebook app
glenngv is offline   Reply With Quote
Old 06-24-2002, 04:31 PM   PM User | #14
ACJavascript
Regular Coder

 
Join Date: Jun 2002
Location: FL, USA
Posts: 734
Thanks: 0
Thanked 0 Times in 0 Posts
ACJavascript is on a distinguished road
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
ACJavascript is offline   Reply With Quote
Old 06-26-2002, 01:48 AM   PM User | #15
cunning-fox
New Coder

 
Join Date: Jun 2002
Posts: 58
Thanks: 0
Thanked 0 Times in 0 Posts
cunning-fox is an unknown quantity at this point
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>
cunning-fox is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 10:45 PM.


Advertisement
Log in to turn off these ads.