Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/52711-open-blank/
Share on other sites

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;

}

Link to comment
https://forums.phpfreaks.com/topic/52711-open-blank/#findComment-260257
Share on other sites

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
      };

Link to comment
https://forums.phpfreaks.com/topic/52711-open-blank/#findComment-260261
Share on other sites

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?

Link to comment
https://forums.phpfreaks.com/topic/52711-open-blank/#findComment-260275
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.