how to open a pdf file from html page??

Discussion in 'HTML & Website Design' started by rrn, Jul 25, 2009.

  1. #1
    i am creating a website in html page , i want to open a pdf file from my html page..
    ie in my website there is a link to location map, wen i click the the 'location map ' , a pdf file should be opened.. tried a lot of ways, pls help me..

    <font color="#0000FF"><p align="center"><a href = 'map.pdf'>Location map</a></p></font>
    HTML:
    will the above code work???

    any help will be appreciated
     
    rrn, Jul 25, 2009 IP
  2. Kerosene

    Kerosene Alpha & Omega™ Staff

    Messages:
    11,366
    Likes Received:
    575
    Best Answers:
    4
    Trophy Points:
    385
    #2
    Try it and see.

    Yes, a simple href should be all you need. As long as Adobe Reader or Foxit is installed on the user's computer, the browser should know what to do with it.
     
    Kerosene, Jul 25, 2009 IP
  3. rrn

    rrn Peon

    Messages:
    54
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    no , it is not working..
    i tried the folloing code



     1. <HTML>
       2. <HEAD>
       3.  
       4.  <script type="text/javascript">
       5. function open_win()
       6. {
       7. window.open("http://wwwtest.com/map.pdf","_blank");
       8. }
       9. </script>
      10. </HEAD>
      11. <form>
      12. <input type="button" onclick="open_win()" value="Location map">
      13. </form>
      14. </BODY>
      15. </HTML>
    
    HTML:

    this is also not working..
    wen i click the button , a new window is opened but it is displaying a message ' requested URL not found ' ..
     
    rrn, Jul 25, 2009 IP
  4. Kerosene

    Kerosene Alpha & Omega™ Staff

    Messages:
    11,366
    Likes Received:
    575
    Best Answers:
    4
    Trophy Points:
    385
    #4
    If you simply want to link to a PDF, then use href. No need for JS.

    <a href="yourpdf.pdf">Click here</a>
     
    Kerosene, Jul 25, 2009 IP
  5. rrn

    rrn Peon

    Messages:
    54
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    ok i tried
    but it is displaying " webpage cannot be found"
     
    rrn, Jul 25, 2009 IP
  6. Kerosene

    Kerosene Alpha & Omega™ Staff

    Messages:
    11,366
    Likes Received:
    575
    Best Answers:
    4
    Trophy Points:
    385
    #6
    Then the problem is with your href then.
    What's the url of the pdf? If you copy and paste it into your browser, and get an error, then there is no pdf at that location.
     
    Kerosene, Jul 26, 2009 IP
  7. dvncfll01

    dvncfll01 Active Member

    Messages:
    608
    Likes Received:
    8
    Best Answers:
    0
    Trophy Points:
    58
    #7
    yes your script works just fine I tested it with a /pdf site I found. just get a valid link and you should be good :)
     
    dvncfll01, Jul 26, 2009 IP