Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7656773
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T12:51:12+00:00 2026-05-31T12:51:12+00:00

I am writing a web page that should store persistent data. In IE, I

  • 0

I am writing a web page that should store persistent data. In IE, I can simply use Userdata Behavior to store data or objects. Besides, Userdata Behavior offers getAttribute and setAttribute methods to customize the stored objects.

But it is not supported by firefox. With localStorage, I can only store strings with a unique key. My question is: is it possible to customize objects stored in localStorage by using similar methods, like getAttribute or setAttribute?

I want to convert the following code to a new one that should wok under firefox by using localStorage. But I have no idea, how to convert the setAttribute and getAttribute methods. Any idea? Thanks a lot in advance.

<style type="text/css">
.storeuserData {
behavior: url(#default#userData);
</style>
<script type="text/javascript">
function fnSaveInput(){
   var oPersist=oPersistForm.oPersistInput;
   oPersist.setAttribute("sPersist",oPersist.value);
   oPersist.save("oXMLBranch");
}
function fnLoadInput(){
   var oPersist=oPersistForm.oPersistInput;
   oPersist.load("oXMLBranch");
   oPersist.value=oPersist.getAttribute("sPersist");
}
</script>
</head>

<body>

<form id="oPersistForm">
    <input class="storeuserData" type="text" id="oPersistInput">
    <input type="button" value="Load" onclick="fnLoadInput()">
    <input type="button" value="Save" onclick="fnSaveInput()">
</form>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T12:51:13+00:00Added an answer on May 31, 2026 at 12:51 pm

    I don’t really know a whole lot about the IE implementation but for local storage you could try something like this:

    function setDataValue(attr, value){
       //If local stoarge var doesn't exist, create it
        if(typeof window.localStorage.mydata == 'undefined') window.localStorage.mydata = '{}';
        //Read data from local storage in to object
        var data = JSON.parse(window.localStorage.mydata);
        //update object
        data[attr] = value;
        //save object back in to local storage
        window.localStorage.mydata = JSON.stringify(data);
    }
    function getDataValue(attr){
        return JSON.parse(window.localStorage.mydata)[attr];
    }
    

    Basically all the two functions above do is read & write to a JavaScript object stored in localstorage (encoded as JSON for storage purposes)

    Your function’s could then be written as:

    function fnSaveInput(){
        var oPersist=oPersistForm.oPersistInput;
        setDataValue('sPersist', oPersist.value);
    }
    function fnLoadInput(){
        var oPersist=oPersistForm.oPersistInput;
        oPersist.value = getDataValue('sPersist');
    }
    

    Please note, i wrote all this code freehand so there could be a few typos/errors in it.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm writing part of a web page that allows a user to build a
I'm writing a web page that will detect which college campus a user is
I am writing a Catalyst web application that presents some data that does not
I'm writing a Safari Extension that adds some functionality to a web page that
I am writing a web app in asp.net. I have an aspx page that
I've been writing a program that can determine any and every data about an
I'm writing a web application that should show very large results on a search
I am writing a web application that has a page that returns a list
I'm writing a web page in ASP.NET. I have some JavaScript code, and I
When writing a query for paging on a web page what is the least

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.