What are possible causes for differing behaviors in jsFiddle and in local context

狂风中的少年 提交于 2019-12-11 07:29:37

问题


Upon invsetigating 'mu is too short's answer to this question, I noticed that I get different behaviour in jsFiddle than in my local context for the exact same script. Any clues as to why that is?

Note: I am not getting any javascript errors in Firefox's error console in the local context.

UPDATE: I tried grabbing the HTML from fiddle.jshell.net/ambiguous/ZEx6M/1/show/light to a local file and loading that local file in Chromium browser and I got the following errors in the javascript console:

  • GET file:///css/normalize.css undefined (undefined) /css/normalize.css
  • GET file:///css/result-light.css undefined (undefined) /css/result-light.css
  • Resource interpreted as Script but transferred with MIME type application/empty jquery.scrollTo-1.4.2.js:-1
  • Resource interpreted as Script but transferred with MIME type text/plain jquery.viewport.js:-1

I can get rid of these javascript errors by downloading the files and modifying the <script> tags, but it doesn't solve the problem. The page still scrolls down to the very bottom. Also these errors appear even in the working (jsFiddle) version.

I also tried the same process in Konqueror. Result: the script does absolutely nothing.


回答1:


Don't use separate files for CSS and javascript. Just bring everything into HTML file (using inline javascript and inline CSS) and you should be OK.

Or, run a web server locally to serve the javascript file (with the correct MIME type) and use relative paths to CSS.



来源:https://stackoverflow.com/questions/6207907/what-are-possible-causes-for-differing-behaviors-in-jsfiddle-and-in-local-contex

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!