runnerjp Posted April 10, 2009 Share Posted April 10, 2009 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 https://forums.phpfreaks.com/topic/153515-solved-how-would-i-display-thins-link-using-php-echo/ Share on other sites More sharing options...
ToonMariner Posted April 10, 2009 Share Posted April 10, 2009 <?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 https://forums.phpfreaks.com/topic/153515-solved-how-would-i-display-thins-link-using-php-echo/#findComment-806607 Share on other sites More sharing options...
runnerjp Posted April 10, 2009 Author Share Posted April 10, 2009 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 https://forums.phpfreaks.com/topic/153515-solved-how-would-i-display-thins-link-using-php-echo/#findComment-806629 Share on other sites More sharing options...
ToonMariner Posted April 10, 2009 Share Posted April 10, 2009 you are using the jquery method - make sure you have jqery available.. if you do so make sure you add the attributes to the new window like width height etc. Link to comment https://forums.phpfreaks.com/topic/153515-solved-how-would-i-display-thins-link-using-php-echo/#findComment-806713 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.