Alex
Alex

Reputation: 1963

Refresh problem in Firefox

In my asp page there is one textbox name "ProductName"

if i write any thing in that textbox and refresh that page , textbox is not clear in firefox. But i open this same page in Internet explore and write any thing in textbox and refresh the page, my textbox comes clear

why textbox not comes clear in FireFox?

This is the html code

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
<title>New Page 1</title>
</head>
<body>
<input type="text" id="ProductName" name="ProductName" style="width:235; height:20" value="">
</body>
</html>

Upvotes: 1

Views: 9669

Answers (9)

Iqbal Kabir
Iqbal Kabir

Reputation: 1610

Server-side solution:

PHP session_start() clears input data. Tested on firefox 103.0.2.

<?php session_start(); ?>


<input type="text" />
<br/><br/>
<select>
    <option>Choice 1</option>
    <option>Choice 2</option>
    <option>Choice 3</option>
    <option>Choice 4</option>
</select>

Upvotes: 0

LuEn
LuEn

Reputation: 11

You can use Ctrl+Shift+R command to force reload (not from cache) (see Page Navigation Shortcuts on http://www-archive.mozilla.org/docs/end-user/moz_shortcuts.html)

Upvotes: 0

Behnam
Behnam

Reputation: 6459

for this problem add

autocomplete="off"

attr to input tag for example:

<input type="text" autocomplete="off" id="ProductName" name="ProductName" style="width:235; height:20" value="">

Upvotes: 1

Oriol
Oriol

Reputation: 288280

HTMLFormElement instances inherit a reset method.

It can be used to clear all forms to its default values:

for(var i=0; i<document.forms.length; ++i)
    document.forms[i].reset();

Upvotes: 1

Gaurav
Gaurav

Reputation: 141

You can add the autocomplete="off" attribute to the input as shown below and it should fix the issue.

<input type="text" id="ProductName" name="ProductName" style="width:235; height:20" value="" autocomplete="off">

Upvotes: 4

alinmircea
alinmircea

Reputation: 49

Actually firefox is stupid that way. Let's say you have a checkbox and when the user clicks to activate that checkbox there is a div that should fade in. The problem here is that if you refresh the page your checkbox will remain active but your div will be hidden. They(firefox) did not think it all the way through and that is .. well stupid. Because of that you have to resort to js workarounds which (I'm not quite fond of).

I do agree that you need to have, at some poin, the same value inside some input, like when you submit a page, there is an error and you need to redirect the user back to the page containing the form. Then yeah!, ok!, you need the values... but to keep the values on refresh , well that s just stupid.

What user enters his details and then just thinks "hm I'll just press f5 now see what happens". If that's the kind of user 'roaming round' your site, please shut it down it's infested with stupidity

Ok so now that that is out of the way.

"change the name attribute on your HTML form elements every time the page loads" this is a bad idea don`t do this...

instead you can use a js function that simply gets the input and sets the value to ""

onpageload:
document.getElementById('inp1').value = '';
document.getElementById('inp2').value = '';
document.getElementById('inp3').value = '';

and so on and so forth. P.S. this is just an example, it's your job to see, what fits for you (be it jquery, prot or whatever); to see if you use a for loop or not; etc

Upvotes: 4

M. M.
M. M.

Reputation: 41

Firefox isn't stupid that way. That's appropriate behavior because presumably the div your fading in occurs on an event e.g. onclick, onchange, etc. And since that event isn't triggered on refresh firefox has no reason to show your div. It's your responsibility to write the js necessary to trigger events onload or when document is ready.

Back to topic: a simple solution is to set the autocomplete attribute of your form to 'off'

That's it.

Upvotes: 4

ionectu
ionectu

Reputation: 71

"Actually firefox is stupid that way." - yes it is.

Another way would be to set autocomplete="off" on the input

Upvotes: 7

Matthew Scharley
Matthew Scharley

Reputation: 132284

This is a feature of Firefox (one I'm quite fond of). There's nothing you can do about it on the server-side.

EDIT:

The longer version: There is something you can do about, but it's very messy. Basically, the way Firefox implements this is it refills in form elements with the same name when the user hits the refresh button.

The workaround is to change the name attribute on your HTML form elements every time the page loads. How you keep track of what you change them too is left to your discretion, but let me just say that as a Firefox user myself, having a website do this would annoy me no end.

Upvotes: 10

Related Questions