got problem loadImage in p5JS

here is the problem when i type the example of loadImage in my js file, and load the image in the folder"assets" which were located between the index.html and sketch.js, there is no image pop up after i run it to browser. i think its simple but i could not get it ,any one help please. Screenshot 2015-05-25 18.20.17

Answers

  • Screenshot 2015-05-25 19.14.58

    while i think its sort of like a bug or capability to Yosemite, because when i try to open the example file from p5.js example of the load image, same issue occur. anyone have some solutions for that?

  • It's almost certainly the browser security feature that restricts the loading of files when opening html pages hosted on the local machine. Solution: run sketches on a server (this can be running locally of course).

  • edited May 2015 Answer ✓
    • I know that advising running HTML files in some server is the standard.
    • But I fail to understand why always omit the fact that Firefox derived browsers don't have such restrictions for local HTML files!
    • I'm starting to think it's some kinda secret, censorshipped knowledge... :-\"
    • If we don't want the hassle to setup some kinda server, just open HTML files in Firefox!
    • Even better, get Firefox Developer Edition: :D

    https://www.mozilla.org/en-US/firefox/developer/

  • I could also have suggested using the Brackets editor which includes a server that you can launch at the press of a button; including live update of HTML/CSS edits; and JS updates on file save. But that forces you to use Chrome and doesn't play well with dev tools :(

    Firefox Dev Edition is bleeding edge, memory sucking and not going to be to everyone's taste. I use it through choice; but it's not really for us to impose our preferences on others :P

    Also in my experience these security restrictions/holes are subject to change; so changing browser is not necessarily a sustainable solution.

  • edited May 2015 Answer ✓
    • In no way I'd advise n1 to use some beta browser as its personal browser.
    • My advise here is for development purposes! :-B
    • It's just that I don't see n1 tipping that Firefox family browsers don't need servers in order to run JS scripts locally, even though Firefox exists long before Chrome & Safari.
    • It's like that every1 got some kinda amnesia about it. 8-}
  • I also try the offline loading in the pc IE10, its the same problem, so i am wondering why the force the html could not load local file, for what?

  • BTW its working on the firefox, than you!

  • Answer ✓

    why the force the html could not load local file

    For the reasons described above: this is a security feature implemented in some browsers (IE, Chrome, Safari) and not in others (Firefox). You'll have this problem whenever you need to load resources (images, sound files, text files etc).

Sign In or Register to comment.