dcsimg
Results 1 to 4 of 4

Thread: How to keep image after refreshing page?

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jun 2018
    Posts
    64

    How to keep image after refreshing page?

    I am using this code to keep text after refreshing page. But what is about image . It doesn't work on them.
    How to keep image after refreshing page?
    Code:
    <script type="text/javascript"> 
    document.getElementById("myUserName").value = getSavedValue("myUserName");         function saveValue(e){
                var id = e.id;
                var val = e.value; 
                localStorage.setItem(id, val);
            }  
            function getSavedValue  (v){
                if (localStorage.getItem(v) === null) {
                    return ""; 
                }
                return localStorage.getItem(v);
            }
    </script>

  2. #2
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    5,458

    Re: How to keep image after refreshing page?

    Hi.
    Maybe you should have a look at client side caching (google it)
    Slow as hell.

  3. #3
    March 2015 Winner kfcSmitty's Avatar
    Join Date
    May 2005
    Location
    Kingston, Ontario
    Posts
    2,150

    Re: How to keep image after refreshing page?

    What are you attempting to accomplish?

    Storing images in base64 would work fine if you want to store them in local storage, but that seems like an abuse of local storage. As saparator said, you should be setting a cache time on your images so when the page reloads it pulls it from the users local browser cache, rather than querying the webserver again.

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Jun 2018
    Posts
    64

    Re: How to keep image after refreshing page?

    Hi all,
    Thanks anyone tried to help me.I found the right solution in the post in the link

    https://forums.asp.net/p/2152664/625...ge+to+another+

    Thank you again

Posting Permissions

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



Featured


Click Here to Expand Forum to Full Width