...

View Full Version : Resolved Saving texarea contents after pagerefresh



defencedog
03-03-2012, 04:37 PM
i want to have the capability similar as that of vbulletin so that if user is writing reply using 'quick reply' & want to move to full editor page the contents be preserved.

@phpbb3 (I am successful needs optimisation)
1] the textarea id is similar both in quick & full reply editors
2] When replying a special string is there in url
my code:

var field = document.getElementById("text_editor_textarea");
if (sessionStorage.getItem("autosave") && document.URL.indexOf("mode=reply") > 0) {
field.value = sessionStorage.getItem("autosave");
}
if (field) {
setInterval(function() {
sessionStorage.setItem("autosave", field.value);
}, 1e3);
}​

Now everone knows this time interval function is heavy for browsers...so I want to start ts only when field.value.length > 0 but I am unable to do so. Any suggestions. Simply this willnt work

if (field && field.value.length > 0) {

defencedog
03-04-2012, 04:47 PM
anyone please giv any suggestion how to enclose setInterval within IF{}()

Philip M
03-04-2012, 05:26 PM
You have marked your thread as "resolved" so everyone will assume that you no longer require a reply.

What is wrong with
if (field.value.length > 0 ) {

or

if ((field) && ( field.value.length > 0)) {

defencedog
03-06-2012, 01:10 PM
You have marked your thread as "resolved" so everyone will assume that you no longer require a reply.

What is wrong with
if (field.value.length > 0 ) {

or

if ((field) && ( field.value.length > 0)) {

sir thnx for replying...
I marked it resolved because I felt that its mostly solved & needs a bit of a thing to make it perfect, sorry for communication gap my first language isn't English

Lets say the user approached a topic page (just like this forum) the moment he visited this page the quick_reply editor or field (as I put that) is empty. He may after some time after reading some replies wish to reply or not at all reply.
Now because the field is initially empty the if loop willnt trigger at all & setInterval function isn't triggered at all

defencedog
03-07-2012, 08:49 AM
any one plz



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum