JavaScript and client side scripting.
Moderator: General Moderators
Dark-Rival
Forum Newbie
Posts: 21 Joined: Thu Apr 15, 2004 5:03 am
Location: Amsterdam
Post
by Dark-Rival » Tue Jun 08, 2004 2:34 am
This might be a very simple question, and I'm almost ashamed to ask it
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... » Tue Jun 08, 2004 3:20 am
Javascript can do this.
But if you only want to run the actions in one page, why not use the include() function?
Dark-Rival
Forum Newbie
Posts: 21 Joined: Thu Apr 15, 2004 5:03 am
Location: Amsterdam
Post
by Dark-Rival » Tue Jun 08, 2004 3:24 am
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... » Tue Jun 08, 2004 6:20 am
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).
Dark-Rival
Forum Newbie
Posts: 21 Joined: Thu Apr 15, 2004 5:03 am
Location: Amsterdam
Post
by Dark-Rival » Tue Jun 08, 2004 6:27 am
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... » Tue Jun 08, 2004 7:33 am
No, that setTimeout code will shut the page it is on, ie. it's own page.
Dark-Rival
Forum Newbie
Posts: 21 Joined: Thu Apr 15, 2004 5:03 am
Location: Amsterdam
Post
by Dark-Rival » Tue Jun 08, 2004 8:18 am
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?
Dark-Rival
Forum Newbie
Posts: 21 Joined: Thu Apr 15, 2004 5:03 am
Location: Amsterdam
Post
by Dark-Rival » Tue Jun 08, 2004 8:44 am
To don't confuse you or myself
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... » Tue Jun 08, 2004 9:10 am
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>
Dark-Rival
Forum Newbie
Posts: 21 Joined: Thu Apr 15, 2004 5:03 am
Location: Amsterdam
Post
by Dark-Rival » Tue Jun 08, 2004 9:39 am
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.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Tue Jun 08, 2004 1:04 pm
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;
Dark-Rival
Forum Newbie
Posts: 21 Joined: Thu Apr 15, 2004 5:03 am
Location: Amsterdam
Post
by Dark-Rival » Wed Jun 09, 2004 3:21 am
It still doesn't work
even with the {$choice} it won't carry a variable to the next page.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Wed Jun 09, 2004 3:28 am
what link does it open?
Dark-Rival
Forum Newbie
Posts: 21 Joined: Thu Apr 15, 2004 5:03 am
Location: Amsterdam
Post
by Dark-Rival » Wed Jun 09, 2004 3:32 am
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.
feyd
Neighborhood Spidermoddy
Posts: 31559 Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA
Post
by feyd » Wed Jun 09, 2004 3:46 am
it's not getting processed by php then.. use the code I posted.