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>';?>

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

 

 

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.