How to open a PDF document in new window use hyperlink?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • mistral

    How to open a PDF document in new window use hyperlink?

    what is correct way open a PDF document in new window use hyperlink? I
    want show images thumbnails linked with PDF files, when click on
    thumbnail, PDF will be opened in new window. Some of PDF files are in
    the same web server, other are in a remote location. Any help will be
    appreciated.
  • Steve Swift

    #2
    Re: How to open a PDF document in new window use hyperlink?

    mistral wrote:
    what is correct way open a PDF document in new window use hyperlink? I
    want show images thumbnails linked with PDF files, when click on
    thumbnail, PDF will be opened in new window. Some of PDF files are in
    the same web server, other are in a remote location. Any help will be
    appreciated.
    If the webservers are configured correctly then any link that points to
    a PDF file will cause the browser to download the content of the PDF
    file and to display it appropriately.

    So, <A HREF=/manual.pdf><IMG SRC=/manual_thumb.gi f></Awill work if
    manual.pdf and manual_thumb.gi f are in the root of the server.

    "appropriately" , when the servers are configured correctly, is a matter
    of choice between the browser and its user.

    I think my server is configured correctly; when I download /test.pdf it
    sends "Content-type: application/pdf" in the HTTP headers, which is
    sufficient to keep most browsers/users happy.

    If you want to name the pdf files anything other than *.pdf then all
    bets are off.

    Does this have anything to do with JavaScript? Not as far as I can see.

    --
    Steve Swift


    Comment

    • mistral

      #3
      Re: How to open a PDF document in new window use hyperlink?

      On Jul 9, 4:37 pm, Steve Swift <Steve.J.Sw...@ gmail.comwrote:
      mistral wrote:
      what is correct way open a PDF document in new window use hyperlink? I
      want show images thumbnails linked with PDF files, when click on
      thumbnail, PDF will be opened in new window. Some of PDF files are in
      the same web server, other are in a remote location. Any help will be
      appreciated.
      >
      If the webservers are configured correctly then any link that points to
      a PDF file will cause the browser to download the content of the PDF
      file and to display it appropriately.
      >
      So, <A HREF=/manual.pdf><IMG SRC=/manual_thumb.gi f></Awill work if
      manual.pdf and manual_thumb.gi f are in the root of the server.
      >
      "appropriately" , when the servers are configured correctly, is a matter
      of choice between the browser and its user.
      >
      I think my server is configured correctly; when I download /test.pdf it
      sends "Content-type: application/pdf" in the HTTP headers, which is
      sufficient to keep most browsers/users happy.
      >
      If you want to name the pdf files anything other than *.pdf then all
      bets are off.
      >
      Does this have anything to do with JavaScript? Not as far as I can see.
      >
      --
      Steve Swifthttp://www.swiftys.org .uk/swifty.htmlhttp ://www.ringers.org .uk
      -----------

      Is absolutely does not matter are webserver are configured and where
      PDF files are located. Some PDF locates somewhere inside web
      directory, some - in Internet. Main thing is specify correct path.

      The idea is always open PDF file in new window, irrespective of any
      circumstances. Plus, control alignment of this window, if
      possible(align -right). Opening PDF in same window is bad, since user
      will close file and will leave from webpage.

      I tried some jscript, but it does not work:

      // Opens PDF links in new windows

      function doPopups()
      {
      if (!document.getE lementsByTagNam e) return false;
      var links = document.getEle mentsByTagName( "a");
      for (var i=0; i < links.length; i++) {
      if (links[i].href.indexOf(' .pdf') !== -1) {
      links[i].onclick =
      function() {
      window.open(thi s.href,'popper' ,'resizable,scr ollbars');
      return false;
      }
      }
      }
      }


      It works, but only with link like this:
      <a href="http://website.uk.com/downloads/manual.pdf"
      target="_blank" >TX handbook</a>

      and not work with links like this:

      <a href="http://www.website.com/pdf/datasheet.pdf"> <img src="http://
      www.sample.com/images/image.jpg" alt=" " border="1" height="250"
      width="100"></a>

      Probably due first link contain 'target="_blank "'. But in that case
      script is useless at all.
      Is there normal stable solution?

      Comment

      • RobG

        #4
        Re: How to open a PDF document in new window use hyperlink?

        On Jul 10, 7:13 am, mistral <polych...@soft home.netwrote:
        On Jul 9, 4:37 pm, Steve Swift <Steve.J.Sw...@ gmail.comwrote:
        >
        >
        >
        mistral wrote:
        what is correct way open a PDF document in new window use hyperlink? I
        want show images thumbnails linked with PDF files, when click on
        thumbnail, PDF will be opened in new window. Some of PDF files are in
        the same web server, other are in a remote location. Any help will be
        appreciated.
        >
        If the webservers are configured correctly then any link that points to
        a PDF file will cause the browser to download the content of the PDF
        file and to display it appropriately.
        >
        So, <A HREF=/manual.pdf><IMG SRC=/manual_thumb.gi f></Awill work if
        manual.pdf and manual_thumb.gi f are in the root of the server.
        >
        "appropriately" , when the servers are configured correctly, is a matter
        of choice between the browser and its user.
        >
        I think my server is configured correctly; when I download /test.pdf it
        sends "Content-type: application/pdf" in the HTTP headers, which is
        sufficient to keep most browsers/users happy.
        >
        If you want to name the pdf files anything other than *.pdf then all
        bets are off.
        >
        Does this have anything to do with JavaScript? Not as far as I can see.
        >
        --
        Steve Swifthttp://www.swiftys.org .uk/swifty.htmlhttp ://www.ringers.org .uk
        >
        -----------
        >
        Is absolutely does not matter are webserver are configured and where
        PDF files are located. Some PDF locates somewhere inside web
        directory, some - in Internet. Main thing is specify correct path.
        >
        The idea is always open PDF file in new window, irrespective of any
        circumstances. Plus, control alignment of this window, if
        possible(align -right). Opening PDF in same window is bad, since user
        will close file and will leave from webpage.
        >
        I tried some jscript, but it does not work:
        >
        // Opens PDF links in new windows
        >
        function doPopups()
        {
         if (!document.getE lementsByTagNam e) return false;
         var links = document.getEle mentsByTagName( "a");
        The document has a links collection, there is no need for
        getElementsByTa gName:

        var links = document.links;

        <URL: http://www.w3.org/TR/DOM-Level-2-HTM...tml#ID-7068919 >

         for (var i=0; i < links.length; i++) {
          if (links[i].href.indexOf(' .pdf') !== -1) {
           links[i].onclick =
            function() {
             window.open(thi s.href,'popper' ,'resizable,scr ollbars');
        A better strategy is to keep a reference to the window and re-use it
        if it's been opened previously and is still open - it helps to prevent
        multiple pop-ups.

             return false;
            }
          }
         }
        It would be a good idea at this point to prevent circular references:

        links = null;
        >
        }
        >
        It works, but only with link like this:
        <a href="http://website.uk.com/downloads/manual.pdf"
        target="_blank" >TX handbook</a>
        >
        and not work with links like this:
        >
        <a href="http://www.website.com/pdf/datasheet.pdf"> <img src="http://www.sample.com/images/image.jpg" alt=" " border="1" height="250"
        width="100"></a>
        >
        Probably due first link contain 'target="_blank "'. But in that case
        script is useless at all.
        Is there normal stable solution?
        No. Browsers are configured by users to deal with pop-ups according
        to the users' wishes. Browsers will also deal with files like PDFs
        differently - mine will open them in a different application and will
        not open a popup.


        --
        Rob

        Comment

        • mistral

          #5
          Re: How to open a PDF document in new window use hyperlink?

          On Jul 10, 1:15 am, RobG <rg...@iinet.ne t.auwrote:
          On Jul 10, 7:13 am, mistral <polych...@soft home.netwrote:
          >
          >
          >
          On Jul 9, 4:37 pm, Steve Swift <Steve.J.Sw...@ gmail.comwrote:
          >
          mistral wrote:
          what is correct way open a PDF document in new window use hyperlink? I
          want show images thumbnails linked with PDF files, when click on
          thumbnail, PDF will be opened in new window. Some of PDF files are in
          the same web server, other are in a remote location. Any help will be
          appreciated.
          >
          If the webservers are configured correctly then any link that points to
          a PDF file will cause the browser to download the content of the PDF
          file and to display it appropriately.
          >
          So, <A HREF=/manual.pdf><IMG SRC=/manual_thumb.gi f></Awill work if
          manual.pdf and manual_thumb.gi f are in the root of the server.
          >
          "appropriately" , when the servers are configured correctly, is a matter
          of choice between the browser and its user.
          >
          I think my server is configured correctly; when I download /test.pdf it
          sends "Content-type: application/pdf" in the HTTP headers, which is
          sufficient to keep most browsers/users happy.
          >
          If you want to name the pdf files anything other than *.pdf then all
          bets are off.
          >
          Does this have anything to do with JavaScript? Not as far as I can see.
          >
          --
          Steve Swifthttp://www.swiftys.org .uk/swifty.htmlhttp ://www.ringers.org .uk
          >
          -----------
          >
          Is absolutely does not matter are webserver are configured and where
          PDF files are located. Some PDF locates somewhere inside web
          directory, some - in Internet. Main thing is specify correct path.
          >
          The idea is always open PDF file in new window, irrespective of any
          circumstances. Plus, control alignment of this window, if
          possible(align -right). Opening PDF in same window is bad, since user
          will close file and will leave from webpage.
          >
          I tried some jscript, but it does not work:
          >
          // Opens PDF links in new windows
          >
          function doPopups()
          {
          if (!document.getE lementsByTagNam e) return false;
          var links = document.getEle mentsByTagName( "a");
          >
          The document has a links collection, there is no need for
          getElementsByTa gName:
          >
          var links = document.links;
          >
          <URL:http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-7068919>
          >
          for (var i=0; i < links.length; i++) {
          if (links[i].href.indexOf(' .pdf') !== -1) {
          links[i].onclick =
          function() {
          window.open(thi s.href,'popper' ,'resizable,scr ollbars');
          >
          A better strategy is to keep a reference to the window and re-use it
          if it's been opened previously and is still open - it helps to prevent
          multiple pop-ups.
          >
          return false;
          }
          }
          }
          >
          It would be a good idea at this point to prevent circular references:
          >
          links = null;
          >
          >
          >
          }
          >
          It works, but only with link like this:
          <a href="http://website.uk.com/downloads/manual.pdf"
          target="_blank" >TX handbook</a>
          >
          and not work with links like this:
          >
          <a href="http://www.website.com/pdf/datasheet.pdf"> <img src="http://www.sample.com/images/image.jpg" alt=" " border="1" height="250"
          width="100"></a>
          >
          Probably due first link contain 'target="_blank "'. But in that case
          script is useless at all.
          Is there normal stable solution?
          >
          No. Browsers are configured by users to deal with pop-ups according
          to the users' wishes. Browsers will also deal with files like PDFs
          differently - mine will open them in a different application and will
          not open a popup.
          >
          --
          Rob
          ----------------

          Just tried this version, no any difference, works the same:

          // Opens PDF links in new windows

          function doPopups()
          {
          if (!document.getE lementsByTagNam e) return false;
          var links = document.links;
          for (var i=0; i < links.length; i++) {
          if (links[i].href.indexOf(' .pdf') !== -1) {
          links[i].onclick =
          function() {
          window.open(thi s.href,'popper' ,'resizable,scr ollbars');
          return false;
          }
          }
          }
          links = null;
          }


          Probably, no needs in javascript at all, since target="_blank" in href
          statement do this.

          <a href="http://website.uk.com/downloads/manual.pdf"
          target="_blank" >TX handbook</a>

          Perhaps use FRAME-based page have more sence.

          Comment

          • mistral

            #6
            Re: How to open a PDF document in new window use hyperlink?

            On 10 ÉÀÌ, 01:35, mistral <polych...@soft home.netwrote:
            On Jul 10, 1:15 am, RobG <rg...@iinet.ne t.auwrote:
            >
            On Jul 10, 7:13 am, mistral <polych...@soft home.netwrote:
            >
            On Jul 9, 4:37 pm, Steve Swift <Steve.J.Sw...@ gmail.comwrote:
            >
            mistral wrote:
            what is correct way open a PDF document in new window use hyperlink? I
            want show images thumbnails linked with PDF files, when click on
            thumbnail, PDF will be opened in new window. Some of PDF files are in
            the same web server, other are in a remote location. Any help will be
            appreciated.
            >
            If the webservers are configured correctly then any link that points to
            a PDF file will cause the browser to download the content of the PDF
            file and to display it appropriately.
            >
            So, <A HREF=/manual.pdf><IMG SRC=/manual_thumb.gi f></Awill work if
            manual.pdf and manual_thumb.gi f are in the root of the server.
            >
            "appropriately" , when the servers are configured correctly, is a matter
            of choice between the browser and its user.
            >
            I think my server is configured correctly; when I download /test.pdf it
            sends "Content-type: application/pdf" in the HTTP headers, which is
            sufficient to keep most browsers/users happy.
            >
            If you want to name the pdf files anything other than *.pdf then all
            bets are off.
            >
            Does this have anything to do with JavaScript? Not as far as I can see.
            >
            --
            Steve Swifthttp://www.swiftys.org .uk/swifty.htmlhttp ://www.ringers.org .uk
            >
            -----------
            >
            Is absolutely does not matter are webserver are configured and where
            PDF files are located. Some PDF locates somewhere inside web
            directory, some - in Internet. Main thing is specify correct path.
            >
            The idea is always open PDF file in new window, irrespective of any
            circumstances. Plus, control alignment of this window, if
            possible(align -right). Opening PDF in same window is bad, since user
            will close file and will leave from webpage.
            >
            I tried some jscript, but it does not work:
            >
            // Opens PDF links in new windows
            >
            function doPopups()
            {
            šif (!document.getE lementsByTagNam e) return false;
            švar links = document.getEle mentsByTagName( "a");
            >
            The document has a links collection, there is no need for
            getElementsByTa gName:
            >
            š var links = document.links;
            >
            <URL:http://www.w3.org/TR/DOM-Level-2-HTML/html.html#ID-7068919>
            >
            šfor (var i=0; i < links.length; i++) {
            š if (links[i].href.indexOf(' .pdf') !== -1) {
            š šlinks[i].onclick =
            š š function() {
            š š šwindow.open(th is.href,'popper ','resizable,sc rollbars');
            >
            A better strategy is to keep a reference to the window and re-use it
            if it's been opened previously and is still open - it helps to prevent
            multiple pop-ups.
            >
            š š šreturn false;
            š š }
            š }
            š}
            >
            It would be a good idea at this point to prevent circular references:
            >
            š links = null;
            >
            }
            >
            It works, but only with link like this:
            <a href="http://website.uk.com/downloads/manual.pdf"
            target="_blank" >TX handbook</a>
            >
            and not work with links like this:
            >
            <a href="http://www.website.com/pdf/datasheet.pdf"> <img src="http://www.sample.com/images/image.jpg" alt=" " border="1" height="250"
            width="100"></a>
            >
            Probably due first link contain 'target="_blank "'. But in that case
            script is useless at all.
            Is there normal stable solution?
            >
            No. šBrowsers are configured by users to deal with pop-ups according
            to the users' wishes. šBrowsers will also deal with files like PDFs
            differently - mine will open them in a different application and will
            not open a popup.
            >
            --
            Rob
            >
            ----------------
            >
            Just tried this version, no any difference, works the same:
            >
            // Opens PDF links in new windows
            >
            function doPopups()
            {
            šif (!document.getE lementsByTagNam e) return false;
            švar links = document.links;
            šfor (var i=0; i < links.length; i++) {
            š if (links[i].href.indexOf(' .pdf') !== -1) {
            š šlinks[i].onclick =
            š š function() {
            š š šwindow.open(th is.href,'popper ','resizable,sc rollbars');
            š š šreturn false;
            š š }
            š }
            š}
            š šlinks = null;
            >
            }
            >
            Probably, no needs in javascript at all, since target="_blank" in href
            statement do this.
            >
            <a href="http://website.uk.com/downloads/manual.pdf"
            target="_blank" >TX handbook</a>
            >
            Perhaps use FRAME-based page have more sence.
            ---

            Any ideas?

            Comment

            • Thomas 'PointedEars' Lahn

              #7
              Re: How to open a PDF document in new window use hyperlink?

              RobG wrote:
              On Jul 10, 7:13 am, mistral <polych...@soft home.netwrote:
              > if (!document.getE lementsByTagNam e) return false;
              > var links = document.getEle mentsByTagName( "a");
              >
              The document has a links collection, there is no need for
              getElementsByTa gName:
              >
              var links = document.links;
              >
              <URL: http://www.w3.org/TR/DOM-Level-2-HTM...tml#ID-7068919 >
              If you read this more thoroughly, you will observe that there may be a need
              to use HTMLDocument::g etElementsByTag Name("a"). The feature test performed
              for it here, however, is inadequate.


              PointedEars
              --
              Use any version of Microsoft Frontpage to create your site.
              (This won't prevent people from viewing your source, but no one
              will want to steal it.)
              -- from <http://www.vortex-webdesign.com/help/hidesource.htm>

              Comment

              Working...