Jump to content

[SOLVED] how would i display thins link using php echo


runnerjp

Recommended Posts

how would i display thins link using php echo

<?php if ($username != $profilesname) echo { '<div align=\"center\"><a href=\"http://www.runningprofiles.com/members/include/friendrequest.php?username=$profilename\"
onclick=\"popUp(this.href,'console',200,500);return false;\"
target=\"_blank\">Add to frinds list</a></div>';?>

Link to comment
Share on other sites

<?php if ($username != $profilesname) echo { '<div align=\"center\"><a href=\"http://www.runningprofiles.com/members/include/friendrequest.php?username=$profilename\"
onclick=\"popUp(this.href,\'console\',200,500);return false;\"
target=\"_blank\">Add to frinds list</a></div>';?>

 

you are right in that javascript should control new winows but try and keep javascript code out of your markup..

 

<?php if ($username != $profilesname) echo { '<div align=\"center\"><a href=\"http://www.runningprofiles.com/members/include/friendrequest.php?username=$profilename\"
class="popup">Add to frinds list</a></div>';?>

 

would be a better solution with the following javascript..

 

$("a.popup").click(function{window.open($(this).attribute("href")); return false;} // jquery


// non jquery solution.
function popUps()
{
var links = document.getElementsByTagName('a');
for(var i = 0; i < links.length; i++)
{
  if (links[i].className && links[i].className == 'popup')
  {
   links[i].onclick = function () {
    window.open(this.href);
    return false;
  }
}
}

window.onload = popUps;

 

 

Link to comment
Share on other sites

ok i used this

 

<?php if ($username != $profilesname)  {echo '<div align=\"center\"><a href=include/friendrequest.php?username='.$profilename.' class="popup">Add to frinds list</a></div>';}?>

 

then i included a file <script type="text/javascript" src="http://www.runningprofiles.com/popup.js"></script>

 

on this is

var newWin = null;
function popUp(strURL, strType, strHeight, strWidth) {
if (newWin != null && !newWin.closed)
   newWin.close();
var strOptions="";
if (strType=="console")
   strOptions="resizable,height="+
     strHeight+",width="+strWidth;
if (strType=="fixed")
   strOptions="status,height="+
     strHeight+",width="+strWidth;
if (strType=="elastic")
   strOptions="toolbar,menubar,scrollbars,"+
     "resizable,location,height="+
     strHeight+",width="+strWidth;
newWin = window.open(strURL, 'newWin', strOptions);
newWin.focus();
}
$("a.popup").click(function{window.open($(this).attribute("href")); return false;} // jquery


// non jquery solution.
function popUps()
{
var links = document.getElementsByTagName('a');
for(var i = 0; i < links.length; i++)
{
  if (links[i].className && links[i].className == 'popup')
  {
   links[i].onclick = function () {
    window.open(this.href);
    return false;
  }
}
}

window.onload = popUps;

 

but no pop up happens...just a normal page redirect

Link to comment
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.