2

First off, I know this question is similar to: Firefox cache textarea value? but mine is slightly different (I think, I'm very inexperience at HTML).

So I have a

<div class='class'><div id='message'><textarea id="msg">msg</textarea></div></div>

I'm trying to disable caching so that when I refresh, it grabs the textarea concent from the server, not from the browser. But I'm only trying for just this textarea. Unfortunately, the contents of the textarea are generated by code, not hardcoded. Can I stick the "autocomplete=off" attribute in one of the divs and will it filter down to the textarea? Or do I have to find out where the code is generated for the textarea and modify that?

[EDIT] (from comment-has-an-answer) So because I don't have control over the markup fields, I had to write a jquery that matched the specific textarea ID. Maybe next time people will actually read the question...

Community
  • 1
  • 1
Smipims
  • 343
  • 1
  • 8
  • 20
  • 1
    Why didn't you google your question first ? https://www.google.ca/search?newwindow=1&site=&source=hp&q=Disable+caching+of+a+textarea+in+firefox It has already been answered zillions of times. – Milche Patern Oct 11 '13 at 14:17
  • 1
    @MilchePatern The OP *did* search and found how to disable this feature. The problem is that they don't have control over the markup for the form fields. – cimmanon Oct 11 '13 at 14:21
  • @cimmanon You are right, with the 'actual' question. Perhaps, my comment was too quick and did not consider the OP was to be elaborated. – Milche Patern Oct 11 '13 at 15:50

4 Answers4

8

As r92 states in this other Stackoverflow answer:

For textarea only:

<textarea autocomplete="off"></textarea>

For all form fields

<form autocomplete="off">

For a javascript solution

document.getElementById( "msg" ).setAttribute( "autocomplete","off" )

For a jQuery solution

$('#msg').attr('autocomplete','off');

Preventing Firefox from remebering the input value on refresh with Meta tag

MSDN Reference and MozillaWiki Reference

The attribute has to be on a form / form-field (never tested) and i don't think this 'attribute' is inherited. So NO, you won't be able to stick it to an outer container.

Community
  • 1
  • 1
Milche Patern
  • 19,632
  • 6
  • 35
  • 52
1

I am pretty sure autocomplete="off" has to be on the textarea itself. You could apply that post render using javascript/jquery:

$('textarea').attr('autocomplete','off');
mconlin
  • 8,169
  • 5
  • 31
  • 37
0

All you need to do is to add autocomplete off in your textarea.

So this should stop browser from remembering you info inside of textarea

<textarea autocomplete="off"></textarea>
Salvador Dali
  • 214,103
  • 147
  • 703
  • 753
0

So because I don't have control over the markup fields, I had to write a jquery that matched the specific textarea ID. Maybe next time people will actually read the question...

Smipims
  • 343
  • 1
  • 8
  • 20