Code Monkey home page Code Monkey logo

Comments (5)

gimite avatar gimite commented on June 29, 2024

Hmm it works fine with my Safari 4.0.4 on WinXP. I don't have Mac so I cannot debug it further myself... A few questions:

  • When it fails? Isn't even "onopen" shown?
  • Is Flash Player installed properly in your Safari? What's version of Flash?
  • Could you follow "How to debug" section in README.txt and let me know what's shown in JavaScript console (and Flash errors?)
  • You can insert console.log to web_socket.js and something equivalent to Flash code to identify which part works properly and which part doesn't.

from web-socket-js.

TooTallNate avatar TooTallNate commented on June 29, 2024

Ok, so after some investigation, I realized that WebSocket.__initialize() was not being called, due to the fact that I was loading "web_socket.js" after the "onload" event had already fired, and thus

window.addEventListener("load", WebSocket.__initialize, false);

wasn't doing the trick. I ended up calling it manually and it worked fine in Safari.

from web-socket-js.

gimite avatar gimite commented on June 29, 2024

I see. So do you use some technique to load web_socket.js dynamically, not with static script tag? I'll try to find way to make it work properly in that case too. Thanks.

from web-socket-js.

TooTallNate avatar TooTallNate commented on June 29, 2024

Precisely, I wasn't using your sample.html, I was using my own test file that was appending the needed <script> nodes to the head in an onload function. So since onload had already been triggered, the addEventListener is web_socket.js was useless.

On top of that, I've retried the sample.html (both on a webserver, and from a trusted file:/// URI) with Safari on my Mac and everything works splendidly. Wish I would have tried that first.

As far as trying to fix it somehow, after a quick Google I found this you could try:
var body = document.getElementsByTagName('BODY')[0];
// CONDITION DOES NOT WORK
if(body && body.readyState == 'loaded') {
DoStuffFunction();
} else {
// CODE BELOW WORKS
if (window.addEventListener) {
window.addEventListener('load', DoStuffFunction, false);
} else {
window.attachEvent('onload', DoStuffFunction);
}
}

EDIT: The code above seems like it might only work in IE... I don't know if there's a universal way of checking if the "onload" event has fired.

from web-socket-js.

gimite avatar gimite commented on June 29, 2024

I see. Thanks for the info.

from web-socket-js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.