Topic: open links and images in new window
hello i want to know how to make images and links open in new window not in the same window .
link: google.com
thank u
You are not logged in. Please login or register.
PunBB Forums → PunBB 1.3 discussion → open links and images in new window
hello i want to know how to make images and links open in new window not in the same window .
link: google.com
thank u
none have the solution ??
Please change image!!
why change the image, it's just a example,
and why u didn't give me the solution ...
where are you admin of this forum, because they are some people had the same problem of me , find us a solution
thank u
Replace Line 609 on 'include/parser.php' with:
return '<a href="'.$full_url.'" target="_blank">'.$link.'</a>';
and Line 627:
$img_tag = '<a href="'.$url.'" target="_blank"><'.$lang_common['Image link'].'></a>';
why change the image, it's just a example,
and why u didn't give me the solution ...
where are you admin of this forum, because they are some people had the same problem of me , find us a solution
thank u
I Joke!
Next time, use the SEARCH button on the site, if you had searched, you would of found the answer, even though the results are for 1.2 it still will show you what you need to edit to get it to work with 1.3.
Fact even the 1.2 tutorial works on 1.3, so you would of been able to get your answer which has been answered before if you search.
http://wiki.punres.org/Open_links_in_a_new_window
thank you very much, i am new here that's why i didn't search in the site.
i joke too fantasma . thank u
This is the patch for PunBB v1.2.20, authored by me (legolas558). It will use target="_blank" only on external URLs.
--- include/parser.php 2009-08-20 08:12:27.000000000 +0200
+++ include/parser.php 2009-08-20 08:11:07.000000000 +0200
@@ -277,7 +277,22 @@
// Ok, not very pretty :-)
$link = ($link == '' || $link == $url) ? ((strlen($url) > 55) ? substr($url, 0 , 39).' … '.substr($url, -10) : $url) : stripslashes($link);
- return '<a href="'.$full_url.'">'.$link.'</a>';
+ return '<a href="'.$full_url.'"'.add_auto_target($full_url).'>'.$link.'</a>';
+}
+
+//
+// Automatically add target="_blank" for URLs not on this website
+//
+function add_auto_target($url) {
+ $p = strpos($url, '//');
+ if ($p !== false) {
+ $url = substr($url, $p+2);
+ $p = strpos($url, '/');
+ $url = substr($url, 0, $p);
+ if ($_SERVER["SERVER_NAME"] == $url)
+ return '';
+ }
+ return ' target="_blank" rel="nofollow"';
}
@@ -288,7 +303,7 @@
{
global $lang_common, $pun_config, $pun_user;
- $img_tag = '<a href="'.$url.'"><'.$lang_common['Image link'].'></a>';
+ $img_tag = '<a href="'.$url.'"'.add_auto_target($url).'><'.$lang_common['Image link'].'></a>';
if ($is_signature && $pun_user['show_img_sig'] != '0')
$img_tag = '<img class="sigimage" src="'.$url.'" alt="'.htmlspecialchars($url).'" />';
Replace Line 609 on 'include/parser.php' with:
return '<a href="'.$full_url.'" target="_blank">'.$link.'</a>';
and Line 627:
$img_tag = '<a href="'.$url.'" target="_blank"><'.$lang_common['Image link'].'></a>';
Thanks a lot! I never thought I would find a solution.
PunBB Forums → PunBB 1.3 discussion → open links and images in new window
Powered by PunBB, supported by Informer Technologies, Inc.