[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

comp.lang.javascript

Prevent refresh when url returns from another app.

Amandeep

4/28/2015 8:04:00 PM

Hi All,

So here is my situation.
I trigger a bar-code scanner app from my webpage, and once the app is open, I am able to scan a bar-code and retrieve it via URL.


NOW, I have multiple input fields on a page that the url lands on. I take the scanned bar-code from the url and put it inside the input fields.

The problem is that when the URL returns with the scanned bar-code, it refreshes the whole page therefore erasing all the previously entered values from input fields.

So, is there a way where I can retrieve the bar-code from the url without refreshing the page.(So that the input fields retain their values). OR how can I retain the values entered in the input fields.

I do not want to go to the server side of the equation. Please provide solutions workable only from the front-end side.

Below is the Fiddle I created. see if that is any help.

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


Thanks in advance.
5 Answers

Evertjan.

4/28/2015 10:02:00 PM

0

Amandeep <maman@google.com> wrote on 28 apr 2015 in comp.lang.javascript:

> So, is there a way where I can retrieve the bar-code from the url
> without refreshing the page.(So that the input fields retain their
> values). OR how can I retain the values entered in the input fields.

var xhr = new XMLHttpRequest();
....etc.
forms[0].elements['myInput'].value = result;

> I do not want to go to the server side of the equation. Please provide
> solutions workable only from the front-end side.

I don't understand this gibberish,
but, as this is not a help desk,
please do not direct us how we should respond.

--
Evertjan.
The Netherlands.
(Please change the x'es to dots in my emailaddress)

JR

4/29/2015 6:50:00 PM

0

On 28/04/2015 19:02, Evertjan. wrote:
> Amandeep <maman@google.com> wrote on 28 apr 2015 in comp.lang.javascript:
>
>> So, is there a way where I can retrieve the bar-code from the url
>> without refreshing the page.(So that the input fields retain their
>> values). OR how can I retain the values entered in the input fields.
>
> var xhr = new XMLHttpRequest();
> ...etc.
> forms[0].elements['myInput'].value = result;
>

Or the HTML5 Fetch API, supported in recent versions of Firefox and Chrome.

--
Joao Rodrigues

Denis McMahon

4/29/2015 11:26:00 PM

0

On Tue, 28 Apr 2015 13:04:02 -0700, Amandeep wrote:

> So, is there a way where I can retrieve the bar-code from the url
> without refreshing the page.(So that the input fields retain their
> values). OR how can I retain the values entered in the input fields.

Use a "background" http request to get the bar code from the url. google
for xmlhttprequest

--
Denis McMahon, denismfmcmahon@gmail.com

Christoph M. Becker

4/29/2015 11:55:00 PM

0

Denis McMahon wrote:

> On Tue, 28 Apr 2015 13:04:02 -0700, Amandeep wrote:
>
>> So, is there a way where I can retrieve the bar-code from the url
>> without refreshing the page.(So that the input fields retain their
>> values). OR how can I retain the values entered in the input fields.
>
> Use a "background" http request to get the bar code from the url. [...]

To get anything from "the url", just use window.location and appropriate
string manipulation functions (regex might come in handy).

Disclaimer: I'm well aware that this doesn't answer the *intended* question.

--
Christoph M. Becker

Thomas 'PointedEars' Lahn

4/30/2015 6:26:00 AM

0

Joao Rodrigues wrote:

> On 28/04/2015 19:02, Evertjan. wrote:
>> Amandeep <maman@google.com> wrote on 28 apr 2015 in comp.lang.javascript:
>>> So, is there a way where I can retrieve the bar-code from the url
>>> without refreshing the page.(So that the input fields retain their
>>> values). OR how can I retain the values entered in the input fields.
>> var xhr = new XMLHttpRequest();
>> ...etc.
>> forms[0].elements['myInput'].value = result;
>
> Or the HTML5 Fetch API, supported in recent versions of Firefox and
> Chrome.

And Opera. But:

<https://developer.mozilla.org/en-US/docs/Web/API/Fet...

| This is an experimental technology
| Because this technology's specification has not stabilized, check the
| compatibility table for [â?¦] use in various browsers.
| Also note that the syntax and behavior of an experimental technology is
| subject to change in future versions of browsers as the spec changes.

In this case, â??recentâ? means only the most recent stable versions have
support for it enabled by default, namely Chrome 42, Firefox 39, and Opera
29. I recommend to not use it for Web sites on the Internet at least at
this point.

--
PointedEars
FAQ: <http://PointedEars.... | SVN: <http://PointedEars.de...
Twitter: @PointedEars2 | ES Matrix: <http://PointedEars.de/es-...
Please do not cc me. / Bitte keine Kopien per E-Mail.