7
Contributors
10
Replies
52
Views
7 Years
Discussion Span
Last Post by almostbob
0

<p>How to show pdf file in web page? ex: www.scribd.com</p>

<iframe id="myFrame" style="display:none" width="500" height="300"></iframe>
<input type="button" value="Open PDF" onclick = "openPdf()"/>
<script type="text/javascript">
function openPdf()
{
var omyFrame = document.getElementById("myFrame");
omyFrame.style.display="block";
omyFrame.src = "test.pdf";
}
</script>
0

aaahh so simple... wy didnt i think of it..
bt then wat if user has disabled javascript on his browser...

<iframe id="myFrame" style="display:none" width="500" height="300"></iframe>
<input type="button" value="Open PDF" onclick = "openPdf()"/>
<script type="text/javascript">
function openPdf()
{
var omyFrame = document.getElementById("myFrame");
omyFrame.style.display="block";
omyFrame.src = "test.pdf";
}
</script>

Edited by venkat0904: n/a

0

aaahh so simple... wy didnt i think of it..
bt then wat if user has disabled javascript on his browser...

To handle the users with javascript disabled , you can add something like this in your script -

<noscript>
  <input type="hidden" name="JavaScript" value="false" />
</noscript>

The parameter should only be submitted if the browser has scripts turned off.So on checking this you can do something like below -

<?php 
if(isset($_POST['JavaScript']) && $_POST['JavaScript'] !='')
{
echo "Turn on your javascript";
}
0

yeah i know about checking if javascript is disabled but what i was actually looking at is if we can do this without javascript...

To handle the users with javascript disabled , you can add something like this in your script -

<noscript>
  <input type="hidden" name="JavaScript" value="false" />
</noscript>

The parameter should only be submitted if the browser has scripts turned off.So on checking this you can do something like below -

<?php 
if(isset($_POST['JavaScript']) && $_POST['JavaScript'] !='')
{
echo "Turn on your javascript";
}
0

yeah i know about checking if javascript is disabled but what i was actually looking at is if we can do this without javascript...

not without the javascript, its a client side thing and need to handle with the client side scripting.

0

ohhh... thanx for that clarification...
Cheers!!

not without the javascript, its a client side thing and need to handle with the client side scripting.

0

Love the tutorial. But I'm looking for a specific solution where php can get some certain pdf files from a folder that contains lot of pdf files and display them in a small thumbnail-like on a web page and click on a particular thumbnail would show the big pdf file on thesame web page. Please would really appreciate a solution to this. Thanks in advance

0

dont forget a 'get reader' link for those (was going to write too dumb but that would be uncharitable) who do not have browsers capable of reading pdf natively

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.