Skip to content
Advertisement

display user name on the heading during onload

I’m making a dynamic website that need to show the user’s name in the heading. The heading should say ‘Hello, ‘, when the user enters their name into the text box and presses the button. And the name has to stay on the page even if I refresh the page.

What will be the javascript functions and html codes to implement this?

However, to implement this, the site need to read the query string when the page is loaded, not when the button is pressed. How can I write functions for the onload event for this?

I’ve tried this, but this doesn’t work.

JavaScript
JavaScript

Advertisement

Answer

Try this code, It might helpfull to you

JavaScript
JavaScript

Local storage wont work with the snippet by the way

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement