opening website in separate window

Dr. GBooky is here to help you with your guestbook problems ...
Post Reply
tomriehl
Posts: 1
Joined: Sat Feb 24, 2007 2:40 am

opening website in separate window

Post by tomriehl »

Script URL:
Version of script:
Hosting company:
URL of phpinfo.php:
URL of session_test.php:
What terms did you try when SEARCHING for a solution:

Write your message below:

anyone know how to get the link "back to site homepage" on the guestbook to open in a separate window

thanks
Klemen
Site Admin
Posts: 10116
Joined: Fri Feb 11, 2005 4:04 pm

Post by Klemen »

Open gbook.php in a plain text editor and on line 987 change

Code: Select all

<a href="'.$settings['website_url'].'">
to

Code: Select all

<a href="'.$settings['website_url'].'" target="_blank">
Klemen, creator of HESK and PHPJunkyardWas this helpful? You can buy me a drink here Image

Image You should follow me on Twitter here

Help desk software | Cloud help desk | Guestbook | Link manager | Click counter | more PHP Scripts ...

Also browse for php hosting companies, read php books, find php resources and use webmaster tools
Henrie
Posts: 1095
Joined: Sun Aug 14, 2005 8:57 pm

Post by Henrie »

Unfortunately the code Klemen gave does not validate as valid xhtml.
In xhtml the target attribute is not allowed anymore.

Proper xhtml coding dictates that the user should have a choice if the link is opened in a new window or in the current window.
In modern browsers use shift+click to open a link in a new window, user ctrl+click to open in a new tab.

Code that validates is this:
Change line 989 (this is the line number i have in PSPad, not 987)

Code: Select all

<p style="text-align:center"><a href="'.$settings['website_url'].'">Back to '.$settings['website_title'].'</a>
to

Code: Select all

<p style="text-align:center"><a onclick="javascript:window.open(\''.$settings['website_url'].'\');">Back to '.$settings['website_title'].'</a>
A problem with this code is that the cursor does not change to a hand on mouseover. To fix this there are two solutions:
Solution 1 (which i would prefer, but unfortunately Firefox still does not show the hand cursor).

Code: Select all

<p style="text-align:center"><a onclick="javascript:window.open(\''.$settings['website_url'].'\');" style="cursor: hand;">Back to '.$settings['website_title'].'</a>
Solution 2 (which has as a setback that the current page is reloaded in the current window, but otherwise works perfectly and does show the hand cursor in all browsers)

Code: Select all

<p style="text-align:center"><a href="" onclick="javascript:window.open(\''.$settings['website_url'].'\');">Back to '.$settings['website_title'].'</a>
Greetings,
Henrie
FruitBeard
Posts: 38
Joined: Thu Jul 21, 2005 6:25 pm

Post by FruitBeard »

Hi there,

In reference to Henrie's solution 1 and the cursor not changing in Firefox browser.
<p style="text-align:center"><a onclick="javascript:window.open(\''.$settings['website_url'].'\');" style="cursor: hand;">Back to '.$settings['website_title'].'</a>
change style="cursor: hand;">

to

change style="cursor: pointer;">

this works in all browsers.

Fruity
FruitFully yours

http://www.fgps.com/keith/
Post Reply