Javascript behaves differently when opened as file:// vs. from local web server - Javascript

This is a discussion on Javascript behaves differently when opened as file:// vs. from local web server - Javascript ; I have been tasked to figure out a way to communicate from a JavaScript /XUL client to a server, but without using a web server. I have been researching different possibilities, and I have come upon <a href = "http://aflax.org">aflax</a>, ...

+ Reply to Thread
Results 1 to 4 of 4

Javascript behaves differently when opened as file:// vs. from local web server

  1. Default Javascript behaves differently when opened as file:// vs. from local web server

    I have been tasked to figure out a way to communicate from a
    JavaScript /XUL client to a server, but without using a web server.


    I have been researching different possibilities, and I have come upon
    <a href = "http://aflax.org">aflax</a>, which is a library for
    imbedding flash in JavaScript. So far I have been able to get it to
    connect, but only if the server script is running locally along with
    the flash content and client. I am using the example of a chat
    program at aflax.org - http://aflax.org/examples/sockets/sockets.html
    .. you can see the example there but unfortunately the demo does not
    work, and Aflax forums have not provided a response.


    1) Why should the HTML file (with JavaScript and Aflax) act
    differently when it is opened as a file:// as opposed to on a
    localhost web server? It does not connect to the server when I simply
    open the file from my filesystem rather than being served it on a web
    server. The Firefox error console notes this error when I use the
    filesystem method: __flash__argumentsToXML is not defined . This
    error is not present when it is served from the web server, but a
    google search doesn't yield any help for me - only the same function
    embedded in lots of other code.

    2) If I run the web server locally and open the HTML file, but run
    the server (simply a perl script), it also does not connect to the
    server. Someone suggested this may relate to setting the
    crossdomain.xml. I Set it the domains to *, and it still did not
    work. Because I am running it on a local LAN, i'm not even sure what
    domain I would put there.

    If this is an inappropriate place to post, I apologize, but I'm really
    grasping at straws here - I don't know if the problem is JavaScript,
    Flash code, Flash player settings, the Aflax library, or what. I did
    go into the flashplayer settings here:
    http://www.macromedia.com/support/do...02.html#118539
    to allow this particular flash file to connect out to the Internet.

    Thanks,
    Nick


  2. Default Re: Javascript behaves differently when opened as file:// vs. fromlocal web server

    Nick wrote:
    > I have been tasked to figure out a way to communicate from a
    > JavaScript /XUL client to a server, but without using a web server.
    >
    > I have been researching different possibilities, and I have come upon
    > <a href = "http://aflax.org">aflax</a>, which is a library for
    > imbedding flash in JavaScript. So far I have been able to get it to
    > connect, but only if the server script is running locally along with
    > the flash content and client. I am using the example of a chat
    > program at aflax.org - http://aflax.org/examples/sockets/sockets.html
    > . you can see the example there but unfortunately the demo does not
    > work, and Aflax forums have not provided a response.


    Having seen the example on the Aflax homepage, that library does not strike
    me as being written by an individual who knows how to employ ECMAScript
    implementations properly.

    > 1) Why should the HTML file (with JavaScript and Aflax) act
    > differently when it is opened as a file:// as opposed to on a
    > localhost web server? It does not connect to the server when I simply
    > open the file from my filesystem rather than being served it on a web
    > server. The Firefox error console notes this error when I use the
    > filesystem method: __flash__argumentsToXML is not defined .


    So it isn't defined, and you have to find out why -- Read the Source, Luke.

    > This error is not present when it is served from the web server, but a
    > google search doesn't yield any help for me - only the same function
    > embedded in lots of other code.


    http://getfirebug.com/

    > I did go into the flashplayer settings here:
    > http://www.macromedia.com/support/do...02.html#118539
    > to allow this particular flash file to connect out to the Internet.


    However, the ECMAScript implementation (here: JavaScript) does not care
    about Flash Player settings, and the Same Origin Policy forbids and
    prevents that kind of access.


    PointedEars
    --
    Prototype.js was written by people who don't know javascript for people
    who don't know javascript. People who don't know javascript are not
    the best source of advice on designing systems that use javascript.
    -- Richard Cornford, cljs, <f806at$ail$1$8300dec7@news.demon.co.uk>

  3. Default Re: Javascript behaves differently when opened as file:// vs. from local web server

    On Oct 25, 1:42 pm, Thomas 'PointedEars' Lahn <PointedE...@web.de>
    wrote:
    > Nick wrote:
    > > I have been tasked to figure out a way to communicate from a
    > > JavaScript /XUL client to a server, but without using a web server.

    >
    > > I have been researching different possibilities, and I have come upon
    > > <a href = "http://aflax.org">aflax</a>, which is a library for
    > > imbedding flash in JavaScript. So far I have been able to get it to
    > > connect, but only if the server script is running locally along with
    > > the flash content and client. I am using the example of a chat
    > > program ataflax.org -http://aflax.org/examples/sockets/sockets.html
    > > . you can see the example there but unfortunately the demo does not
    > > work, andAflaxforums have not provided a response.

    >
    > Having seen the example on theAflaxhomepage, that library does not strike
    > me as being written by an individual who knows how to employ ECMAScript
    > implementations properly.
    >
    > > 1) Why should the HTML file (with JavaScript andAflax) act
    > > differently when it is opened as a file:// as opposed to on a
    > > localhost web server? It does not connect to the server when I simply
    > > open the file from my filesystem rather than being served it on a web
    > > server. The Firefox error console notes this error when I use the
    > > filesystem method: __flash__argumentsToXML is not defined .

    >
    > So it isn't defined, and you have to find out why -- Read the Source, Luke.


    The reference to that function in the library / aflax.js file is all
    there is. Adobe's docs don't show any help here either:
    http://www.google.com/search?q=site%...ient=firefox-a
    About the only place I can find someone referring to this function
    (and not simply listing some code) is here:
    http://lists.deconcept.com/pipermail...ly/000794.html
    ..

    So I still don't really know what to make of it - unless my opening
    the file locally, some library or other file is not being loaded,
    which has the definition in it.
    >
    > > This error is not present when it is served from the web server, but a
    > > google search doesn't yield any help for me - only the same function
    > > embedded in lots of other code.

    >
    > http://getfirebug.com/
    >
    > > I did go into the flashplayer settings here:
    > >http://www.macromedia.com/support/do...hplayer/help/s...
    > > to allow this particular flash file to connect out to the Internet.

    >
    > However, the ECMAScript implementation (here: JavaScript) does not care
    > about Flash Player settings, and the Same Origin Policy forbids and
    > prevents that kind of access.

    I have downloaded firebug and will try to use that. I had not heard
    of the Same Origin Policy, but according to this:
    http://en.wikipedia.org/wiki/Same_origin_policy , it doesn't apply if
    I am opening the file locally.

    Thank you for responding, I would appreciate any more direction here.

    nick


  4. Default Re: Javascript behaves differently when opened as file:// vs. fromlocal web server

    Nick wrote:
    > [...] Thomas 'PointedEars' Lahn [...] wrote:
    >> Nick wrote:
    >>> I did go into the flashplayer settings here:
    >>> http://www.macromedia.com/support/do...hplayer/help/s...
    >>> to allow this particular flash file to connect out to the Internet.

    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    >> However, the ECMAScript implementation (here: JavaScript) does not care
    >> about Flash Player settings, and the Same Origin Policy forbids and
    >> prevents that kind of access.

    >
    > [...] I had not heard of the Same Origin Policy, but according to this:
    > http://en.wikipedia.org/wiki/Same_origin_policy , it doesn't apply if
    > I am opening the file locally.


    Unless I have misunderstood you, you are trying to open a resource with a
    http:// URI from a resource accessed with a file:// URI. The Same Origin
    Policy forbids that and there is no workaround other than in Geckos to lower
    the UA's security settings via a user preference (which strongly recommended
    against nowadays).


    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>

+ Reply to Thread

Similar Threads

  1. std::getline() behaves differently between platforms?
    By Application Development in forum c++
    Replies: 6
    Last Post: 11-22-2007, 06:10 AM
  2. info globals behaves differently in 8.4.6 and 8.4.9
    By Application Development in forum TCL
    Replies: 1
    Last Post: 04-25-2007, 09:10 AM
  3. info globals behaves differently in 8.4.6 and 8.4.9
    By Application Development in forum TCL
    Replies: 0
    Last Post: 04-25-2007, 02:31 AM
  4. Font behaves differently in CS2 vs InDesign
    By Application Development in forum Adobe illustrator
    Replies: 2
    Last Post: 12-13-2006, 09:49 AM
  5. CCur called from ASP behaves differently under Win2003!!!
    By Application Development in forum Inetserver
    Replies: 1
    Last Post: 10-01-2003, 09:37 PM