sjakalen Posted May 23, 2007 Share Posted May 23, 2007 Can someone help me, I have a link that I want to open in a new window, target="_blank" the sentence look like this:: $member_yimbit = ifelse($row['yim'], makelink("http://bf2s.com/player/".$row['yim'] . "/"), $str['NOTAVAILABLE']); This works it just dont open blank I dont want to change the sentence to somthing that look like this:: echo "<a href=\"http://bf2s.com/player/".$row['yim'] . "\" target=\"_blank\">test</a>"; This dont work at all Quote Link to comment https://forums.phpfreaks.com/topic/52711-open-blank/ Share on other sites More sharing options...
Lumio Posted May 23, 2007 Share Posted May 23, 2007 why not? <?php if (isset($row['yim'])) { ?><a href="<?= 'link'.$row['yim'] ?>" target="_blank">link</a><?php } ?> Quote Link to comment https://forums.phpfreaks.com/topic/52711-open-blank/#findComment-260253 Share on other sites More sharing options...
sjakalen Posted May 23, 2007 Author Share Posted May 23, 2007 If I change $member_yimbit = ifelse($row['yim'], makelink("http://bf2s.com/player/".$row['yim'] . "/"), $str['NOTAVAILABLE']); to if (isset($row['yim'])) { ?><a href="<?= 'link'.$row['yim'] ?>" target="_blank">link</a> the page will not open Quote Link to comment https://forums.phpfreaks.com/topic/52711-open-blank/#findComment-260254 Share on other sites More sharing options...
Wuhtzu Posted May 23, 2007 Share Posted May 23, 2007 you could change your makelink() function to accept to parameters: function makelink($link,$target = false) { if($target) { make a link which contains a target= } else { make a link which contains no target } } Quote Link to comment https://forums.phpfreaks.com/topic/52711-open-blank/#findComment-260255 Share on other sites More sharing options...
sjakalen Posted May 23, 2007 Author Share Posted May 23, 2007 ok that sounds like a good idea, can you also help me do it?? function makelink look like this:: function makelink($link,$name,$title="",$target="",$completeurl=0,$cutname=0,$maxwidth=60,$startwidth=40,$endwidth=-15) { if (!trim($name)) { $name = $link; } if ($completeurl == 1) { $link = checkUrlFormat($link); } if (strlen($name) > $maxwidth && $cutname == 1) { $name = substr($name, 0, $startwidth) . "..." . substr($name, $endwidth); } $link = "<a href=\"" . $link . "\" target=\"" .$target . "\" title=\"" . $title . "\">" . $name . "</a>"; return $link; } Quote Link to comment https://forums.phpfreaks.com/topic/52711-open-blank/#findComment-260257 Share on other sites More sharing options...
chigley Posted May 23, 2007 Share Posted May 23, 2007 Just found this better version when Googling about, accepts a $target. <?php function makelink($linkedtext, $linkhref, $kind=0, $fragment="", $title="", $target="_top") { //*$kind values: 0 means internal; 1 means external; global $outputas; $class = ($kind==0)? 'internal' : 'external'; if ($kind==0) { if (substr($linkhref, -1)=='/') { if ($outputas=='offline') { $linkhref .= "index.html"; //* you can't have links to dirs when offline } } else { if ($outputas=='online' || $outputas=='offline') { $linkhref.='.html'; } else { $linkhref.='.php4'; } }; }; echo "<A HREF=\"$linkhref$fragment\" CLASS=\"$class\" TITLE=\"$title\" TARGET=\"$target\">"; echo "$linkedtext</A>"; if ($outputas=='print' && $kind==1) { echo " <SMALL>[$linkhref]</SMALL>"; }; //* for printed things, I want to write URLs in brackets after links }; Quote Link to comment https://forums.phpfreaks.com/topic/52711-open-blank/#findComment-260261 Share on other sites More sharing options...
sjakalen Posted May 23, 2007 Author Share Posted May 23, 2007 I dont know it I dont understand you right, but changeing my "function makelink" to the one you write, dont work. the page can open but write all links on the top of the page. Quote Link to comment https://forums.phpfreaks.com/topic/52711-open-blank/#findComment-260268 Share on other sites More sharing options...
per1os Posted May 23, 2007 Share Posted May 23, 2007 Looking at the function you provided, I do not think you understand the usage: <?php function makelink($link,$name,$title="",$target="",$completeurl=0,$cutname=0,$maxwidth=60,$startwidth=40,$endwidth=-15) { if (!trim($name)) { $name = $link; } if ($completeurl == 1) { $link = checkUrlFormat($link); } if (strlen($name) > $maxwidth && $cutname == 1) { $name = substr($name, 0, $startwidth) . "..." . substr($name, $endwidth); } $link = "<a href=\"" . $link . "\" target=\"" .$target . "\" title=\"" . $title . "\">" . $name . "[/url]"; return $link; } $link = makelink("http://bf2s.com/player/" . $row['yim'] . "/", 'myLink', 'My Link Title', '_blank'); echo $link; ?> Does that work for you? Quote Link to comment https://forums.phpfreaks.com/topic/52711-open-blank/#findComment-260275 Share on other sites More sharing options...
sjakalen Posted May 23, 2007 Author Share Posted May 23, 2007 That works Thanks !!!!! The bedst help I ever got Quote Link to comment https://forums.phpfreaks.com/topic/52711-open-blank/#findComment-260285 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.