1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

how to open a .PDF document in same window ?

Discussion in 'JavaScript' started by eonelite, Jun 20, 2008.

  1. #1
    I need help, I have a .PDF document and when a user clicks the link, I want it to open in the same window, not a new browser window, it shouldn't use the whole browser window, only specific width and height. Anyone know a code or something...

    Appreciate it !

    \eonelite
     
    eonelite, Jun 20, 2008 IP
  2. desertst0rm

    desertst0rm Peon

    Messages:
    330
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    0
    #2
    upload it to scribd.com and embed it to your site
     
    desertst0rm, Jun 21, 2008 IP
  3. koolman

    koolman Peon

    Messages:
    76
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #3
    You can use iframe to open the pdf file, when mouse click set src of iframe to pdf file.
     
    koolman, Jun 21, 2008 IP
  4. eonelite

    eonelite Peon

    Messages:
    2
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Can you give me a code ?
     
    eonelite, Jun 22, 2008 IP
  5. koolman

    koolman Peon

    Messages:
    76
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #5
    It would be something like bellow:
    
    <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 = "myFile.pdf";
      }
    </script>
    
    PHP:
     
    koolman, Jun 22, 2008 IP
    ThePHPMaster likes this.
  6. code-rush

    code-rush Guest

    Messages:
    25
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #6
    ^^ Simple, yet effective. :)
     
    code-rush, Jun 23, 2008 IP
  7. prasun27

    prasun27 Member

    Messages:
    33
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    36
    #7
    Use iframe it can be a good alternative.
     
    prasun27, Jun 11, 2015 IP
  8. deathshadow

    deathshadow Acclaimed Member

    Messages:
    9,732
    Likes Received:
    1,998
    Best Answers:
    253
    Trophy Points:
    515
    #8
    Just make sure there's an option to download the PDF instead of forcing the crappy browser UI to try and get around it. There's a REASON I disable the PDF plugin for browsers as PDF's opening in a browser just pisses me off as a user.

    That said, sounds like you want an OBJECT tag, or if you give a flying purple fish about "standards" use an iframe.
     
    deathshadow, Jun 13, 2015 IP
  9. rizwanaegis1942

    rizwanaegis1942 Greenhorn

    Messages:
    3
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    21
    #9
    I have Use iframe it will give you results as per you need
     
    rizwanaegis1942, Jun 29, 2015 IP