Hi friends,
I want to go to previous page from a pdf document page using php. I already used the following code.

<a href='javascript:history.go(-1)'>

It only works on the web pages but it doesn't work in pdf document.

Recommended Answers

All 2 Replies

A PDF document is displayed by a plugin in the browser. It's not possible to control these with Javascript.

As workaround you can use an iframe to display the pdf and place the history.back link in the page, something like:

<html>
<head><title>go back</title></head>
<body>
    <p><a href="javascript:history.go(-1)">prev</a></p>
    <iframe width="900px" height="600px" frameborder="0" src="view.html" />
</body>
</html>

and in the view.html you place an object tag or a plugin as suggested by pritaeas:

<object width="850px" height="550px" type="application/pdf" data="/pdf/pdf_to_display.pdf"></object>
EDIT

well, I did a test.. you don't even need the iframe, just use:

<html>
<head><title>go back</title></head>
<body>
    <p><a href="javascript:history.go(-1)">prev</a></p>
    <object width="850px" height="550px" type="application/pdf" data="/pdf/pdf_to_display.pdf"></object>
</body>
</html>

bye!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.