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>';?> Quote Link to comment 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; Quote Link to comment 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 Quote Link to comment 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. Quote Link to comment 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.