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

<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>

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>

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";
}

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";
}

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.

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

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

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

I will apply those codes for my website. Thanks dude.

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

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.