Page 1 of 2

Opening 2 links with 1 click

Posted: Tue Jun 08, 2004 2:34 am
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

Posted: Tue Jun 08, 2004 3:20 am
by Grim...
Javascript can do this.

But if you only want to run the actions in one page, why not use the include() function?

Posted: Tue Jun 08, 2004 3:24 am
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 :(

Posted: Tue Jun 08, 2004 6:20 am
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).

Posted: Tue Jun 08, 2004 6:27 am
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??

Posted: Tue Jun 08, 2004 7:33 am
by Grim...
No, that setTimeout code will shut the page it is on, ie. it's own page.

Posted: Tue Jun 08, 2004 8:18 am
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?

Posted: Tue Jun 08, 2004 8:44 am
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

Posted: Tue Jun 08, 2004 9:10 am
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>

Posted: Tue Jun 08, 2004 9:39 am
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.

Posted: Tue Jun 08, 2004 1:04 pm
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;

Posted: Wed Jun 09, 2004 3:21 am
by Dark-Rival
It still doesn't work :( even with the {$choice} it won't carry a variable to the next page.

Posted: Wed Jun 09, 2004 3:28 am
by feyd
what link does it open?

Posted: Wed Jun 09, 2004 3:32 am
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.

Posted: Wed Jun 09, 2004 3:46 am
by feyd
it's not getting processed by php then.. use the code I posted.