javascript - jsFiddle not working in Chrome -
recently created fiddle following code -
html
<button onclick="action();">click me<img src="http://dummyimage.com/200x200/000000/fff.gif&text=image+1" width="200px" id="imagebutton1"></button>
js
function action ( ) { if(document.getelementbyid("#imagebutton1").src == 'http://dummyimage.com/200x200/000000/fff.gif&text=image+1' ) document.getelementbyid("#imagebutton1").src = 'http://dummyimage.com/200x200/dec4ce/fff.gif&text=image+2'; else document.getelementbyid("#imagebutton1").src = 'http://dummyimage.com/200x200/000000/fff.gif&text=image+1'; }
fiddle link - http://jsfiddle.net/qvrug/4/
this code working in ff
, in local html
file throws error in chrome
console -
uncaught referenceerror: action not defined
i further investigated error , found -
uncaught referenceerror function defined in onload function
so tried -
window.action = function(){...code here...};
but no luck :(
kindly let me know behavior why not working in chrome , working others. please don't provide patch make fiddle working interested behavior. descriptive answers(with relevant link further study) appreciated in case can move in rest of projects.
let me know if question not on track, take down(although put honest efforts make question clean , clear)
it's because "language" set javascript 1.7
in jsfiddle.
why work in firefox?
according versioning history, 1.7
ever supported in mozilla firefox browser, hence why works there , not in other browsers.
solution:
change language javascript 1.7
javascript
in languages section of jsfiddle , work. i'm guessing must have changed 1.7 specifically, because default javascript
(you can see pasting code new jsfiddle, work expected).
Comments
Post a Comment