Page 2 of 3 FirstFirst 123 LastLast
Results 11 to 20 of 23

Thread: pdf within an iframe

  1. #11
    Join Date
    Nov 2014
    Location
    On A Scottish Island
    Posts
    488
    Thanks
    0
    Thanked 62 Times in 58 Posts

    Default

    The w3schools.com "iframe" page has this line right at the start:

    Code:
    <iframe src="http://www.w3schools.com"></iframe>
    Now what you need to do is go back to that page, scroll down to the list describing the various attributes that an iframe can have and read about the purpose of the "src" attribute.

  2. #12
    Join Date
    Nov 2015
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I hope people understand what I am saying , I have a drop down menu on my site, and each link will linkto a different study, and i want each study, one at a time to show up in the iframe, I am trying to eliminate as much web pages possible on my website, actually I just want to web pages.

    Thanks in advance.

  3. #13
    Join Date
    Nov 2014
    Location
    On A Scottish Island
    Posts
    488
    Thanks
    0
    Thanked 62 Times in 58 Posts

    Default

    Quote Originally Posted by Glett View Post
    I hope people understand what I am saying , I have a drop down menu on my site, and each link will linkto a different study, and i want each study, one at a time to show up in the iframe, I am trying to eliminate as much web pages possible on my website, actually I just want to web pages.

    Thanks in advance.
    Now you have explained what you are trying to achieve a little more clearly, I think you would get better results using PHP. Serve the second page with the appropriate content by a call from the first page passing a parameter to the second. All the hard work is then done on the server.

  4. #14
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    Quote Originally Posted by Glett View Post
    I hope people understand what I am saying , I have a drop down menu on my site, and each link will linkto a different study, and i want each study, one at a time to show up in the iframe, I am trying to eliminate as much web pages possible on my website, actually I just want to web pages.

    Thanks in advance.
    OK, I think I understand what you're trying to do now. I would opt for PHP - if you can use PHP you can do something like this.

    For the links (on any page);
    Code:
    <a href="page.php?s=study1">Page 1</a>  
    <a href="page.php?s=study2">Page 2</a>  
    <a href="page.php?s=study3">Page 3</a>
    And in the 'page.php' page with the iframe, put this right at the top - even before the doctype (very simple - untested);
    Code:
    <?php  
    
    if ( (isset($_GET['s'])) && ($_GET['s'] == 'study1') ) { $src = 'path/to/study-01.pdf'; } 
    
    if ( (isset($_GET['s'])) && ($_GET['s'] == 'study2') ) { $src = 'path/to/study-02.pdf'; } 
    
    if ( (isset($_GET['s'])) && ($_GET['s'] == 'study3') ) { $src = 'path/to/study-03.pdf'; } 
    
    ?>
    And then further down in your HTML you echo the $src variable into your iframe src attribute;
    Code:
    <iframe src="<?php echo $src ;?>"></iframe>
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  5. #15
    Join Date
    Nov 2015
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Ok it seems to want to work but what it dispalys in the iframe is page not found. I called my page studies.php , and in the links I put:
    Code:
    <a href="mystudies.php?s=study1">Page 1</a>  
    <a href="mystudies.php?s=study2">Page 2</a>  
    <a href="mystudies.php?s=study3">Page 3</a>
    and in the php quote (which my program already put the <?php ?> tags) I put:
    Code:
    <?php
    if ( (isset($_GET['s'])) && ($_GET['s'] == 'study1') ) { $src = 'https://onedrive.live.com/embed?cid=0912027297A21B07&resid=912027297A21B07%218989&authkey=AD_ol5nd3vdkIvY&em=2&wdStartOn=1&wdEmbedCode=0&wdPrint=0'; } 
    
    if ( (isset($_GET['s'])) && ($_GET['s'] == 'study2') ) { $src = 'C:\Users\ASUS\Documents\My Websites\HisCross\Hiscrosstester\Grace.pdf'; } 
    
    if ( (isset($_GET['s'])) && ($_GET['s'] == 'study3') ) { $src = 'Grace.pdf'; } 
    ?>
    and for the iframe which appears with the links, I put:

    Code:
    <iframe src="<?php echo $src ;?>"></iframe>
    But when I click the links , the pdf files do not show up , even though they are the right file path.

    I think we are going in the right direction with this php code just need to get the pdf's tp show, thanks a whole lot.
    Last edited by Beverleyh; 11-10-2015 at 06:47 PM. Reason: formatting

  6. #16
    Join Date
    Nov 2015
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    The pdf's did not show up on the desktop side of things but when I uploaded it to my test website server , it worked just great , does php only function on the server side? and not on the client side (hope I am saying this stuff right)? Anyhow thanks alot Beverleyh and styxlawyer.

  7. #17
    Join Date
    Nov 2015
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    I will try it out on my real website now and let you's know how things go.

  8. #18
    Join Date
    Nov 2014
    Location
    On A Scottish Island
    Posts
    488
    Thanks
    0
    Thanked 62 Times in 58 Posts

    Default

    The first of those files is on the web, the second is on your local drive and the third might be anywhere.

    How are you testing this? If it's on a local machine you will need to run a server (like XAMPP) on that machine so that the PHP interpreter will execute. However, if it's on a web server you will not be able to open a file on your own computer. Either way something isn't going to work.

    Edited to add: Ah, too slow in typing. You have found that PHP doesn't run on your local machine unless you have an Apache server installed like XAMPP. It looks as though you are making progress.

  9. #19
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    even though they are the right file path
    The 1st one should work.

    The 2nd one wont work online because the path is local for your computer.

    The 3rd one should again work, provided the 'Grace.pdf' file is in the same folder as the 'mystudies.php' page, and the letter-case matches (Unix systems are case-sensitive, Windows isnt)

    You should check that your server is parsing the PHP - after clicking one of the links, view the page source to see what is printed in the iframe's src attribute. Each should look like this in turn;

    Code:
    <iframe src="https://onedrive.live.com/embed?cid=0912027297A21B07&resid=912027297A21B07%218989&authkey=AD_ol5nd3vdkIvY&em=2&wdStartOn=1&wdEmbedCode=0&wdPrint=0"></iframe>
    
    <iframe src="C:\Users\ASUS\Documents\My Websites\HisCross\Hiscrosstester\Grace.pdf"></iframe>
    
    <iframe src="Grace.pdf"></iframe>
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

  10. #20
    Join Date
    Jul 2008
    Location
    Derbyshire, UK
    Posts
    3,033
    Thanks
    25
    Thanked 599 Times in 575 Posts
    Blog Entries
    40

    Default

    Quote Originally Posted by Glett View Post
    The pdf's did not show up on the desktop side of things but when I uploaded it to my test website server , it worked just great , does php only function on the server side? and not on the client side (hope I am saying this stuff right)? Anyhow thanks alot Beverleyh and styxlawyer.
    Things are getting confusing because your replies are fragmented. Posting in quick succession might also lead you into bother with the spam filtering so try to keep your replies together in one post where possible.

    Yes, PHP is a server-side language so it needs to run on a server. You can run one locally, such as WAMP or XAMPP. Otherwise, upload to your web host (like you have) and it will work there.
    Focus on Function Web Design
    Fast Edit (A flat file, PHP web page editor & CMS. Small, FREE, no database!) | Fast Edit BE (Snippet Manager) (Web content editor for multiple editable regions!) | Fast Apps

Similar Threads

  1. Including external content: standard iframe, hidden iframe or Ajax?
    By molendijk in forum Coding tips & tutorials threads
    Replies: 0
    Last Post: 10-19-2011, 07:34 PM
  2. Pop over Parent from iframe, feed data from Popup back to iframe
    By cclambie in forum Dynamic Drive scripts help
    Replies: 0
    Last Post: 12-05-2007, 10:38 AM
  3. Replies: 3
    Last Post: 10-17-2007, 03:50 PM
  4. Iframe scrollbar color and Monthly iframe content
    By big-dog1965 in forum JavaScript
    Replies: 1
    Last Post: 09-12-2007, 07:04 AM
  5. Replies: 0
    Last Post: 06-16-2005, 03:16 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •