Page 1 of 1

opening website in separate window

Posted: Sat Feb 24, 2007 2:45 am
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

Posted: Sat Feb 24, 2007 4:48 pm
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">

Posted: Sat Feb 24, 2007 10:29 pm
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

Posted: Sun Feb 25, 2007 3:59 pm
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