简体   繁体   中英

how to sessionstorage slider value

here are my code,

`<script src="main.js"></script>
<script type="text/javascript">
wwr_start();
function onSliderChanged(slider) {
    wwr_req(`SET/TRACK/${slider.id}/VOL/${slider.value}`);


            
            <label class="drx"> Stax </label>
            <input class= "raa" type=range min=0 max=3 value=1 step=any id="3"          oninput="onSliderChanged(this)">

by the way, i excluded my css style code.to give you brief explanation of my code, it's volume controller for my digital audio mixer. "id" in range input represent track number of my mixer so can't really change to something else. So i would like my last slider value (the slider position) to be remained where it was even when i refresh the page. i treid to use sessionstorage but couldn't really figure out how. i googled, and researched a little of how to use, it seems like i have to use json stringfy option to store slider value to sessionstorage and load out when it's refreshed. can anyone help me out please? i'm pretty new at coding and kind of running out of time to study from scratch

i tried to use sessionstorage but couldn't figur eout

Write into sessionStorage:

sessionStorage.slide = JSON.stringify(this.slide)) , the slide is the key you set into session storage.

Catch at local:

let final = JSON.parse(sessionStorage.slide) , you can get the key from session storage, then set it as a variable final to execute the following things.

The content as mentioned above is a simple concept which not use your actual code to demonstrate, so please do not copy the code directly for your project:)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM