Skip to content
Advertisement

Tag: html

How to store objects in HTML5 localStorage/sessionStorage

I’d like to store a JavaScript object in HTML5 localStorage, but my object is apparently being converted to a string. I can store and retrieve primitive JavaScript types and arrays using localStorage, but objects don’t seem to work. Should they? Here’s my code: The console output is It looks to me like the setItem method is converting the input to

How to create an on/off switch with Javascript/CSS?

I want to have a sliding switch. On the left would be Off and on the right would be On. When the user toggles the switch, I want the ‘slider’ portion to slide to the other side and indicate it is off. I could then have a callback that takes as input the state of the toggle switch so I

What are the reasons to use the id attribute for CSS purposes? [closed]

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. Closed 10 years ago.

Reading cookie expiration date

Is it possible to read cookie expiration date using JavaScript? If yes, how? If not, is there a source I can look at? Answer It is not possible to get the expiration date of a cookie through Javascript; only key-value pairs are exposed through document.cookie.

Href=”#” Don’t Scroll

I am pretty new to JS – so just wondering whether you know how to solve this problem. Current I have in my code Which runs some JS to close a box. The problem I have is that when the user clicks on the link – the href=”#” takes the user to the top of page when this happens. How

Disable pasting text into HTML form

Is there a way using JavaScript to disable the ability to paste text into a text field on an HTML form? E.g. I have a simple registration form where the user is required to input their email twice. The second email entry is to verify there are no typos in the first email entry. However if the user copy/pastes their

Advertisement