dynamically creating a image that links to 2 other URLs

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
hanhao
Forum Newbie
Posts: 14
Joined: Mon May 22, 2006 10:58 am

dynamically creating a image that links to 2 other URLs

Post 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
User avatar
aerodromoi
Forum Contributor
Posts: 230
Joined: Sun May 07, 2006 5:21 am

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

Post 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
User avatar
ok
Forum Contributor
Posts: 393
Joined: Wed May 31, 2006 9:20 am
Location: The Holy Land

Post 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>
matthijs
DevNet Master
Posts: 3360
Joined: Thu Oct 06, 2005 3:57 pm

Post 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.
hanhao
Forum Newbie
Posts: 14
Joined: Mon May 22, 2006 10:58 am

Post 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
User avatar
ok
Forum Contributor
Posts: 393
Joined: Wed May 31, 2006 9:20 am
Location: The Holy Land

Post by ok »

It would be:

Code: Select all

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