Javascript Tutorials

Use Javascript to Highlight Text

Javascript can be used as a handy way to highlight some text for a user when they click on it. This nifty little feature is useful as it saves time for the user since they don't have to do any clicking and dragging.

To utilize this feature, we use the javascript onclick event and assign certain actions to it. For example, if we had a textbox with some text in, we would enable automatic highlighting when a user clicked inside of it like so:

<textarea onclick="this.focus();;">

Add to Bookmarks Javascript for All Browsers

First of all, the title of this post is a bit misleading. No JavaScript code or any code for that matter can claim to add a bookmark in all browsers. What we can say though, is that the code we present has been tested to work in all major browsers except Google Chrome.

Bookmarks come in handy when it comes to building visitor loyalty and getting visitors to come back to your site. The JavaScript code snippet we show in this article creates a simple hyperlink which, when clicked, requests that the browser add the current page to its list of bookmarks.