Jump to content
  • 0

Desktop web browser behaves different from mobile web browser


Question

Hi all, i hope someone can help me out.

I have a tabular search form with details form.

I have implemented default values on the dropdowns in the search form.

The defaults are set in the datapageready and beforeformsubmit events using localstorage,

This works fine from the desktop chrome browser but not from my mobile phone also using chrome browser.

Here is the code snippet:

<script type="text/javascript">
document.addEventListener('DataPageReady', function (event) {

     if (typeof(Storage) !== "undefined") {
         if(localStorage.getItem("continent") !== null && localStorage.getItem("continent") !== "") {
            document.getElementsByName("Value2_1")[0].value = localStorage.getItem("continent");
         } else {
            document.getElementsByName("Value2_1")[0].value =  "1";
         }
     } else {
           alert ("Sorry! No Web Storage support..");
     }

     // stop for sometime if needed
     setTimeout(setCountry, 1000);
});

function setCountry() {
     if (typeof(Storage) !== "undefined") {
         if(localStorage.getItem("country") !== null && localStorage.getItem("country") !== "") {
            document.getElementsByName("Value3_1")[0].value =  localStorage.getItem("country");
         } else {
            document.getElementsByName("Value3_1")[0].value ="1";
         }
     } else {
           alert ("Sorry! No Web Storage support..");
     }

     var event = new Event('change');
     document.getElementsByName("Value3_1")[0].dispatchEvent(event);


    // stop for sometime if needed   
    setTimeout(setLanguage, 1000);
}

function setLanguage() {
     if (typeof(Storage) !== "undefined") {
         if(localStorage.getItem("language") !== null && localStorage.getItem("language") !== "") {
alert ("Language is already set in DataPageReady to " + localStorage.getItem("language"));
            document.getElementsByName("Value4_1")[0].value =  localStorage.getItem("language");
         } else {
            document.getElementsByName("Value4_1")[0].value = "1";
         }
     } else {
           alert ("Sorry! No Web Storage support..");
     }

     var event = new Event('change');
     document.getElementsByName("Value4_1")[0].dispatchEvent(event);

   // stop for sometime if needed    
    setTimeout(setCultureFeature, 1000);
}

function setCultureFeature() {
     if (typeof(Storage) !== "undefined") {
         if(localStorage.getItem("culturefeature") !== null && localStorage.getItem("culturefeature") !== "") {
            document.getElementsByName("Value5_1")[0].value = localStorage.getItem("culturefeature");
         } else {
            document.getElementsByName("Value5_1")[0].value =   "6";
         }
     } else {
           alert ("Sorry! No Web Storage support..");
     }

     var event = new Event('change');
     document.getElementsByName("Value5_1")[0].dispatchEvent(event);
}

document.addEventListener('BeforeFormSubmit', function (event) {
     if (typeof(Storage) !== "undefined") {   
localStorage.setItem("continent",document.getElementsByName("Value2_1")[0].value);
localStorage.setItem("country",document.getElementsByName("Value3_1")[0].value);
localStorage.setItem("language",document.getElementsByName("Value4_1")[0].value);
localStorage.setItem("culturefeature",document.getElementsByName("Value5_1")[0].value);
     } else {
           alert ("Sorry! No Web Storage support..");
     }
});
</script>

 

Link to post
Share on other sites

1 answer to this question

Recommended Posts

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...