javascript - Prevent refresh when url returns from another app -


i trigger bar-code scanner app webpage, , once app open, able scan bar-code , retrieve via url.

now, have multiple input fields on page url lands on. take scanned bar-code url , put inside input fields.

the problem when url returns scanned bar-code, refreshes whole page therefore erasing entered values input fields.

so, there way can retrieve bar-code url without refreshing page (so input fields retain values) or how can retain values entered in input fields.

and not want go server side of equation. please provide solutions workable front-end side.

below fiddle created. see if help.

<input type="text" id="inputtooutput1" class="scannedoutput"><br><br> <input type="text" id="inputtooutput2" class="scannedoutput"><br><br> <input type="text" id="inputtooutput3" class="scannedoutput"><br><br> <a class="openscanner" href=""><button>open scanner</button></a> 

http://jsfiddle.net/villageboy/cxr6srvo/

something should work: https://jsfiddle.net/1o6xl6vg/5/

if want other values persisted (already filled barcodes) need add them return url.

$.urlparam = function(name){     var results = new regexp('[\?&amp;]' + name + '=([^&amp;#]*)').exec(window.location.href);     return results[1] || 0; }  $('.openscanner').click(function(){     var url = window.location.href+"?code=%7bcode%7d";     $(this).attr({         href:'http://zxing.appspot.com/scan?ret='+url+'&scan_formats=upc_a,ean_13',          target:"nw"     }); }); $(function() {     alert($.urlparam('code'));     $('#inputtooutput1').val($.urlparam('code')); }); 

i'm not sure why can't read parameter jsfiddle problem. best try out on server.


Comments

Popular posts from this blog

java - Spring Data JPA: Why findOne(id) executing delete query internally? -

python - Mongodb How to add addtional information when aggregating? -

java - Incorrect order of records in M-M relationship in hibernate -