Opening 2 links with 1 click

JavaScript and client side scripting.

Moderator: General Moderators

User avatar
Dark-Rival
Forum Newbie
Posts: 21
Joined: Thu Apr 15, 2004 5:03 am
Location: Amsterdam

Opening 2 links with 1 click

Post by Dark-Rival »

This might be a very simple question, and I'm almost ashamed to ask it :P but how do I open 2 links with 1 click. Both pages have actions in it, so is it also possible to run trough both of the pages and then at the end open just one of them? This way all the actions will be performed correctly and the user doesn't have to deal with pop-ups.

So is this all possible? If so, how..
Thanks
Grim...
DevNet Resident
Posts: 1445
Joined: Tue May 18, 2004 5:32 am
Location: London, UK

Post by Grim... »

Javascript can do this.

But if you only want to run the actions in one page, why not use the include() function?
User avatar
Dark-Rival
Forum Newbie
Posts: 21
Joined: Thu Apr 15, 2004 5:03 am
Location: Amsterdam

Post by Dark-Rival »

Well the problem with that is, I have to include a ASP page, with an action in the URL so the include tag won't work with that :(
Grim...
DevNet Resident
Posts: 1445
Joined: Tue May 18, 2004 5:32 am
Location: London, UK

Post by Grim... »

Dark-Rival wrote:I have to include a ASP page
Boo!
Hiss!

Anyway...

Stick this code in between your <head></head> tags to open the new windows:

Code: Select all

<script language="JavaScript"><!--
window1=window.open('test1.html','','scrollbars=yes,width=175,height=300')
window2=window.open('test2.html','','scrollbars=yes,width=175,height=300')
//--></script>
Add this to your <body> tag to close the page after x milliseconds:

Code: Select all

<BODY onLoad="setTimeout(window.close, 5000)">
(5000 = 5 seconds).
User avatar
Dark-Rival
Forum Newbie
Posts: 21
Joined: Thu Apr 15, 2004 5:03 am
Location: Amsterdam

Post by Dark-Rival »

Thanks a lot for your help guys. Just one last question, you meant
<BODY onLoad="setTimeout(window(and the window number here).close, 5000)"> right??
Grim...
DevNet Resident
Posts: 1445
Joined: Tue May 18, 2004 5:32 am
Location: London, UK

Post by Grim... »

No, that setTimeout code will shut the page it is on, ie. it's own page.
User avatar
Dark-Rival
Forum Newbie
Posts: 21
Joined: Thu Apr 15, 2004 5:03 am
Location: Amsterdam

Post by Dark-Rival »

The whole problem with this is the fact that I need to send the variables trough the URL. For example submit.php?id=$quarid and stuff, and this can't be done in javascript right?
User avatar
Dark-Rival
Forum Newbie
Posts: 21
Joined: Thu Apr 15, 2004 5:03 am
Location: Amsterdam

Post by Dark-Rival »

To don't confuse you or myself :P I need to open 2 pages with one link, one needs to stay open and the other window needs to close. Both of these links will send trough variables. These are the two pages that I want to open with only one click:

processmsg.aspMessageID=$messageid&Action=DelMsg
deletemsg.php?id=$messageid
Grim...
DevNet Resident
Posts: 1445
Joined: Tue May 18, 2004 5:32 am
Location: London, UK

Post by Grim... »

To send variables

Code: Select all

<script language="JavaScript"><!-- 
window1=window.open('test1.asp?id=5','','scrollbars=yes,width=175,height=300') 
window2=window.open('test2.php?id=887','','scrollbars=yes,width=175,height=300') 
//--></script>
User avatar
Dark-Rival
Forum Newbie
Posts: 21
Joined: Thu Apr 15, 2004 5:03 am
Location: Amsterdam

Post by Dark-Rival »

With that I still can't open a php variable
'test1.asp?id=5' is a defined id, but I need to define the id trough the $id variable

'test1.asp?id=$quarantineid' and then it won't work. I also tried
'test1.asp?id=<?php echo "$quarantineid"; ?>' and that does work in HTML forms.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

Code: Select all

echo <<<STOP
<script language="Javascript">
<!--
window1 = window.open('test.asp?id={$choice1}', '', 'scrollbars=yes,width=175,height=300');
window1 = window.open('test.asp?id={$choice2}', '', 'scrollbars=yes,width=175,height=300');
//-->
</script>
STOP;
User avatar
Dark-Rival
Forum Newbie
Posts: 21
Joined: Thu Apr 15, 2004 5:03 am
Location: Amsterdam

Post by Dark-Rival »

It still doesn't work :( even with the {$choice} it won't carry a variable to the next page.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

what link does it open?
User avatar
Dark-Rival
Forum Newbie
Posts: 21
Joined: Thu Apr 15, 2004 5:03 am
Location: Amsterdam

Post by Dark-Rival »

This is what it looks like now:

<script language="Javascript">
<!--
window1 = window.open('handlemail.php?id={$quarantineid}', '', 'scrollbars=yes,width=175,height=300');
window1 = window.open('handlemail.asp?id={$quarantineid}', '', 'scrollbars=yes,width=175,height=300');
//-->
</script>

Besides this the handlemail.asp needs to send trought he following actions:
handlemail.asp?MessageID=$quarantineid&Action=AppMsg

It will send {$quarantineid} trough as plane text.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

it's not getting processed by php then.. use the code I posted.
Post Reply