0

How to open links (in pdf document) in new tab or window by using javascript ?

This one is not working :

<a href=\"javascript: w=window.open('http://google.com') w.print(); w.close();\">Click</a>

This one is not working too :

$js = <<<EOD
function openw(url) {
    app.window.open(url,"PDF");
}
EOD;

$pdf->IncludeJS($js);

The sample of above: <a href="javascript:openw(http://google.com)" target="_blank">Click</a>

Any advice or something ?

Yasin Yörük
  • 1,500
  • 7
  • 27
  • 51

1 Answers1

0

Remove backslashes and you forgot a semicolon after w=window.open('http://google.com'):

<a href="javascript: w=window.open('http://google.com'); w.print(); w.close();">Click</a>

If you want to open the window and print it and then close it again, then this one should work.

Andy
  • 2,892
  • 2
  • 26
  • 33
  • in internet explorer print(); doesn't work so you will have to click the print button of the browser to print the page – Andy May 24 '13 at 15:25
  • maybe you should try to load the print() function inside of the new window when it has loaded – Andy May 24 '13 at 15:32
  • I'm not interested with printing page. I found that code from somewhere and It was worked with Opera. So I can delete print() function. I only want to open links in new window which are in pdf document. P.S. : PDF document open with web browser. – Yasin Yörük May 27 '13 at 08:10