So I've working on a website and i'm just doing the finishing touches, I've used a lot of javascript on this and it keeps showing within the print version of the site... even if I comment it out, I was just wondering if anyone was aware of a way of removing javascript from the print version of the site easily, and if it's any help, the site is written in PHP.
Thanks for reading.
EDIT: The javascript itself is not running, its directly showing the code itself, rather than running it, and if possible I would like to remove all the javascript elements entirely.
Can you try this PHP code:
$str = file_get_contents("http://stackoverflow.com");
$pattern = '#\<script.*?\>(.*?)\<\/script\>#si';
$str = preg_replace($pattern, '', $str);
die($str);
It removes all script tags from inside. Now you can print it...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With