Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5
  1. #1
    New Coder
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    86
    Thanks
    20
    Thanked 0 Times in 0 Posts

    Saving texarea contents after pagerefresh

    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:
    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
    Code:
    if (field && field.value.length > 0) {

  • #2
    New Coder
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    86
    Thanks
    20
    Thanked 0 Times in 0 Posts
    anyone please giv any suggestion how to enclose setInterval within IF{}()

  • #3
    Supreme Master coder! Philip M's Avatar
    Join Date
    Jun 2002
    Location
    London, England
    Posts
    18,154
    Thanks
    203
    Thanked 2,548 Times in 2,526 Posts
    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)) {

    All the code given in this post has been tested and is intended to address the question asked.
    Unless stated otherwise it is not just a demonstration.

  • #4
    New Coder
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    86
    Thanks
    20
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Philip M View Post
    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

  • #5
    New Coder
    Join Date
    Mar 2011
    Location
    Pakistan
    Posts
    86
    Thanks
    20
    Thanked 0 Times in 0 Posts
    any one plz


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •