How To Open PDFs in a New Window with JavaScript

Introduction

Opening documents such as PDFs in a new window should be automated using JavaScript for the following reasons:1. Users will often close the web browser when a PDF is opened, mistakenly believing the document has been opened in Adobe Reader2. The attribute historically used to open a new window, target, has been removed from the HTML 4.01 Strict specification (it's now deprecated)3. Opening a new window is a behaviour and should be moved to the behavioural layer1.

Using JavaScript can also be particularly useful when a website is content managed. Rather than having to rely on site editors to remember to open a link to a PDF in a new window the process is handled by a simple JavaScript function.

No comments:

Welcome to CodingWeb

CodingWeb is a rich source of finding tutorials, code, sessions, podcasts and above all demos of all the tutorials shared by the community. It is a rich collection of PHP, Mysql, HTML & CSS tutorials. I hope you find it useful.