How To Open PDFs in a New Window with JavaScript


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 Reader
2. 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.

Continue Reading

No comments: