html - jquery Checking Image Height width server issue -
i have jquery checks image height , width. works in jfiddle.net
but doesn't not work on server or on local machine. have tried in ie , chrome. said both work in jsfiddle not in production. thanks
<script language="javascript" type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script> <script type='text/javascript'> var _url = window.url; $("#myfile").change(function () { var file, img; if ((file = this.files[0])) { img = new image(); img.onload = function () { if (this.width != 57) { alert('please ensure image width 57'); document.getelementbyid('myfile').value = ""; } else if (this.height != 59) { alert('please ensure image height 59'); document.getelementbyid('myfile').value = ""; } else { //alert('perfect'); } }; img.src = _url.createobjecturl(file); } }); </script> <input type="file" id="myfile" />
i believe it's because jsfiddle automatically wraps code in $(document).ready() ( or maybe $(window).load() ).
in actual code, need yourself. ie
$(document).ready(function(){ //all jquery code here });
Comments
Post a Comment