I was bored yesterday and I was scrolling through the projects which are completed for the ‘Give Your Website a Pulse’ mission and they are very creative! But there was one problem in almost all of their projects.
The problem was that the content which people enter in the searchbar is of two types:
Keyword or a query just like how we search on Google.
URL or a website link.
And the website has only one searchbar which is either redirecting to “google.com/search?q=[content-in-searchbar]” or “https://[content-in-searchbar]” according to what the developer has written in the code.
What if the user searched for a query and it redirects him to https://keyword (or) if the user searched for a URL and it redirects him to google.com/search?q=userurl.com . It’s really annoying!
To prevent this, the code should be structured to check if the entered content is a URL, if yes - redirect him to that website; if no - redirect him to a google search.
After doing some research on how to validate a URL, I got to know about URL Object Validation in Javascript. Thanks to this guide, it helped me implement the URL validation in my website. I’ve also added two lines of code just to ensure that the https:// gets added to the URL, incase the user doesn’t enter it.
I’ve added the feature of localStorage which automatically saves the text typed by the user in the notepad window and loads it the next time he returns to the website. There’s no worry of losing the data now!
Along with that I’ve added a feature of minimizing or closing the notepad window and you can see a notepad icon at the bottom left of your screen after minimizing it!
Comments 0
No comments yet. Be the first!
Sign in to join the conversation.