Page 1 of 1

dynamically creating a image that links to 2 other URLs

Posted: Sun Jun 04, 2006 4:36 am
by hanhao
hi, i need to dymaically create a thumbnail button that when the user clicks on it, it does 2 things
so i need to call php to echo out <a href commands

1. links to another page called (page1.php)
2. popup another page in new browser called (page2.php) but set this popup in the background

but the problem is <a href only allows 1 page to be linked
how do i do the above?
can anyone show me an example of what should be written in the php echo command?

please help

- hanhao

Re: dynamically creating a image that links to 2 other URLs

Posted: Sun Jun 04, 2006 4:59 am
by aerodromoi
hanhao wrote:hi, i need to dymaically create a thumbnail button that when the user clicks on it, it does 2 things

1. links to another page called (page1.php)
2. popup another page in new browser called (page2.php) but set this popup in the background

but the problem is <a href only allows 1 page to be linked
how do i do the above?

please help
Take a look at the JavaScript function window.open();
However, there is no guarantee that a user has JavaScript enabled, so I'd recommend putting an "ordinary" link on each page as well.

aerodromoi

Posted: Sun Jun 04, 2006 5:00 am
by ok
It's HTML and JS and not PHP... But...

Code: Select all

<a href="page1.php" onClick="window.open('page2.php');">Click Here</a>

Posted: Sun Jun 04, 2006 5:02 am
by matthijs
Using the href it's not possible, so you'll probably have to use javascript to do this. But I'm not sure if js is able to open multiple windows (check the client side forum here).

but if I may ask, why would you want to open up a second window in the background? for most users that would probably be very confusing.

Posted: Sun Jun 04, 2006 5:54 am
by hanhao
ok wrote:It's HTML and JS and not PHP... But...

Code: Select all

<a href="page1.php" onClick="window.open('page2.php');">Click Here</a>
i need it created dynamically
so in php it would be this?

Code: Select all

echo "<a href="page1.php" onClick="window.open('page2.php');">Click Here</a>";
i am creating a 2nd window for a processing script in MYSQL
after it processes, i'll kill it

Posted: Sun Jun 04, 2006 5:58 am
by ok
It would be:

Code: Select all

echo "<a href=\"".$url_page_1."\" onClick=\"window.open('".$url_page_2."');\">Click Here</a>";