window.open issue

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

    window.open issue

    Hi All,

    I am attempting to do something I thought would be simple. From one
    of my asp.net pages, I need for the user to be able top open up
    documents(any file format - .xls, .doc, .pdf, etc). To accomplish
    this, I am using javascript:

    <code>
    <script type="text/javascript">
    function open_win()
    {
    window.open('fi le://C:/DEV/Procurement2008/ProcurementSyst em/Images/
    dbStylemaster.p pt')
    }
    </script>
    </code>

    I am getting "Access is Denied".

    This file I am trying to open is on my hard drive and I am running the
    asp.net program locally as I am developing. Eventually, the files
    will be stored on a web server.

    I have done a lot of searching this morning and am just more
    confused. Am I attempting to do something that won't be allowed
    because of security?

    Thansk in advance for your help!

    JCC
  • Thomas 'PointedEars' Lahn

    #2
    Re: window.open issue

    JCCDevel wrote:
    I am attempting to do something I thought would be simple. From one
    of my asp.net pages, I need for the user to be able top open up
    documents(any file format - .xls, .doc, .pdf, etc). To accomplish
    this, I am using javascript:
    >
    <code>
    This is Usenet. Please do not bother (us) with pseudo-tags.
    <script type="text/javascript">
    function open_win()
    {
    window.open('fi le://C:/DEV/Procurement2008/ProcurementSyst em/Images/
    dbStylemaster.p pt')
    For a proper file:// URI, you need to add another slash before the C: to
    specify the local host. (The `localhost' host name after it is optional then.)

    But this method only constitutes overhead.
    }
    </script>
    </code>
    >
    I am getting "Access is Denied".
    ^^^^^^^^^^^^^^^ ^
    This file I am trying to open is on my hard drive and I am running the
    asp.net program locally as I am developing. Eventually, the files
    will be stored on a web server.
    >
    I have done a lot of searching this morning and am just more
    confused. Am I attempting to do something that won't be allowed
    because of security?
    That much would be obvious, would it not?

    You are attempting to access a file:// resource from a http(s):// resource.
    The client application does not care, because it cannot know, that both are
    on the same machine. So access is denied.


    PointedEars
    --
    realism: HTML 4.01 Strict
    evangelism: XHTML 1.0 Strict
    madness: XHTML 1.1 as application/xhtml+xml
    -- Bjoern Hoehrmann

    Comment

    • Laurent vilday

      #3
      Re: window.open issue

      Thomas 'PointedEars' Lahn a écrit :
      JCCDevel wrote:
      >I am attempting to do something I thought would be simple. From one
      >of my asp.net pages, I need for the user to be able top open up
      >documents(an y file format - .xls, .doc, .pdf, etc). To accomplish
      >this, I am using javascript:
      >>
      ><code>
      >
      This is Usenet. Please do not bother (us) with pseudo-tags.
      This is Usenet. Don't talk in the name of the whole group, don't say
      *us* there is no "us".

      Talk in your OWN name, thanks.

      --
      laurent

      Comment

      • wayne

        #4
        Re: window.open issue

        On Aug 4, 1:43 pm, JCCDevel <JCCMo...@gmail .comwrote:
        window.open('fi le://C:/DEV/Procurement2008/ProcurementSyst em/Images/
        You could write a tiny http "server" for the localhost, e.g. listening
        on ip 127.0.0.1:80 then use URL of the form http://c/path where this
        tiny server converts /c/path into c:\path to open and read whole file
        into a buffer, then send it to the socket. I have done something like
        that (also for code development) by rigging our existent http server
        source (the iPhone remote desktop & file server, http://f2p.com ) with
        that kind of custom file i/o. You can probably find some tiny http
        server source on the web and spend few hours on customization. That
        scheme also lets you dump js debug strings (e.g. via XMLHttpRequest)
        to the console on the server side, without disrupting display on the
        client side.

        Comment

        • Thomas 'PointedEars' Lahn

          #5
          Re: window.open issue

          wayne wrote:
          On Aug 4, 1:43 pm, JCCDevel <JCCMo...@gmail .comwrote:
          >window.open('f ile://C:/DEV/Procurement2008/ProcurementSyst em/Images/
          >
          You could write a tiny http "server" for the localhost, e.g. listening on
          ip 127.0.0.1:80 then use URL of the form http://c/path where this tiny
          server converts /c/path into c:\path to open and read whole file into a
          buffer, then send it to the socket.
          ISTM this server would listen, but would not hear anything. In this URI,
          `c' would be the host name, and that is what would have to be defined in the
          local `hosts' file as an alias for `localhost', as an alternative DNS record
          would be either invalid or complicate maintenance.
          I have done something like that (also for code development) by rigging
          our existent http server source (the iPhone remote desktop & file server,
          http://f2p.com ) with that kind of custom file i/o.
          That was probably http://localhost/c/...
          You can probably find some tiny http server source on the web and spend
          few hours on customization.
          I would probably use a very basic TCP sockets based service instead; I
          hacked one together using a Java tutorial[1] in about one hour, about 120
          LOC (pretty-printed). I had written almost no Java code before; if you can
          write J(ava)Script, you can also write this one. (Eclipse, of course, came
          in very handy :))

          However, the OP already has a local server with ASP .NET; I recommend to use
          the existing infrastructure instead.


          PointedEars
          ___________
          [1] Abts, Dietmar: Masterkurs Client/Server-Programmierung mit Java;
          pp. 106; 2. Auflage; April 2007; Vieweg & Sohn.
          --
          realism: HTML 4.01 Strict
          evangelism: XHTML 1.0 Strict
          madness: XHTML 1.1 as application/xhtml+xml
          -- Bjoern Hoehrmann

          Comment

          • wayne

            #6
            Re: window.open issue

            That was probably http://localhost/c/...

            Yep, I dopped accidentally the host above.

            Comment

            Working...