Refresh problem in Firefox

2019-02-15 23:13发布

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>

8条回答
虎瘦雄心在
2楼-- · 2019-02-15 23:48

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">
查看更多
做个烂人
3楼-- · 2019-02-15 23:52

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

查看更多
登录 后发表回答