1
  <a href="'.$links['data']['html'].'"> <font color="red">Click Here</font></a></p><br/></div>';

this code in ECHO line. All I want to open this on new popup frame. I tried all things but didnt work.

<a href="javascript:NewWindow=window.open(\'LİNK ADRESİ\',\'newWin\',\'width=520,height=610,left=0,top=0,toolbar=No,location=No,scrollbars=No,status=No,resizable=No,fullscreen=No\');  NewWindow.focus();void(0);">Click HERE!</a>

this worked but its goes wrong link and I cant redirect .$links['data']['html'].

1 Answers1

0

I strongly recommend you to split backend and frontend code as much as possible. You should have a frontend JS file in order to handle the js, where you can bind an action to this link on click event.

You can use your PHP as a backend + template engine delivering HTML, then have a JS file to handle frontend logic.

If you want to stick to it try something like:

<a href="javascript:window.open('<? echo $links['data']['html'];?>')">Click HERE!</a>
Javier Cobos
  • 1,172
  • 10
  • 22
  • I think that instead of inline JS you shuold try to write a small JS script to handle the onclick. This is what you are looking for: https://stackoverflow.com/questions/1070760/javascript-function-in-href-vs-onclick – Javier Cobos Oct 14 '17 at 16:15
  • It's very inappropriate, to be honest. You just need to try till you echo the url inside the window.open first parameter if you want to go on line this. I don't see the point of doing an echo of the whole HTML line. You should either use a template engine like Smarty or Twig, or just use normal PHP as template engine like here: https://stackoverflow.com/questions/4977529/using-php-as-a-template-engine – Javier Cobos Oct 14 '17 at 16:21
  • I found it finally :D figured it by myself – Kerem Aygül Oct 15 '17 at 09:51
  • Congratulations! a vote would be appreciated to get some points :) – Javier Cobos Oct 15 '17 at 10:28
  • It says "Votes cast by those with less than 15 reputation are recorded," Do u know how can I open popup as new tab? I mean I cant open a new tab on popup. – Kerem Aygül Oct 15 '17 at 10:47