View Full Version : Make it open in a new tab instead of a pop up window

10-08-2011, 03:29 PM
Hello everyone,
i kinda stuck at this point on my php script, it has this javascript code and i stuck there

Line 16:

echo("<script language=\"JavaScript\">\nfunction openptc(tpge,pnme,w,h){\nsettings=\"width=\" + w + \",height=\" + h + \",scrollbars=yes,location=no,directories=no,status=1,menubar=no,toolbar=no,resizable=no\";\nwindow.open(tpge,pnme,settings);\n}\n//-->\n</script>");

Line 72:

print "<td><a href=\"#\" onClick=\"openptc('./paidtoclick.php?adid=$row[linkid]&action=start&".session_name()."=".session_id()."','PaidtoClickPage','640','480');\"><b>Click Here To View</b></a><tr>";

I think those 2 lines actually are my problem
I hope you won't get stuck because it's php and javascript and html.

This code makes the site open in a new pop up window. how to make it open in a new tab

Logic Ali
10-08-2011, 04:47 PM
This code makes the site open in a new pop up window. how to make it open in a new tabThat's the user's choice, not yours.
Millions are still suffering from IE6, which predates the point where everyone copied Opera and implemented tabbed browsing.

10-09-2011, 05:21 PM
@Theofilaktos Right now, there is no way YOU can open a link in a tab. This is set by the browser. All people that use tabs have things set so a new window opens the tab. Pop-ups will still open pop-ups.

So, you need to open your link as a new window and let the user decide how he wants to treat that. Erase the javascript function and change the bottom code.
BUT LOOK at bottom code = It starts with <td> and you never close this. You end the line with <tr>. I will assume you are using the wrong tag and close the <td>.
FYI an echo executes slightly faster then the print, so it's preferred.

Just use this in the html link:

echo "<td><a href=\"paidtoclick.php?adid=$row[linkid]&action=start&session_name()=".session_id()."\"><b>Click Here To View</b></a></td>";

I am curious. Why are you writing your code as php and echoing it out?