Welcome to W3Courses
 Like Us on Facebook

JavaScript

Create Close Window Button using JavaScript

Use the following code to add a button to your hml page which on click will close the browser window for that page.

<form>
<input type="button" value="Close Window" onClick="window.close()">
</form>

<a href="javascript:window.close()">Close Window</a>
 

Share

Prompt an Automatic Add to Favorite popup window with 10 second delay using JavaScript

Prompt an Automatic Add to Favorite Popup window 10 seconds after a user visits your website. Add the following code to the body section of your html document

<SCRIPT LANGUAGE="JavaScript">
<!-- //Hide From Old Browsers

/* Do Not Remove the Following Line
   For more scripts visit http://www.w3courses.com
*/

//Change the following link to yours
var link = "http://www.w3courses.com";

Share

Prompt an automatic Add to Favorite Popup Window using JavaScript

Prompt an automatic Add to Favorite Popup window when a user visits your website. Add the following code to the head section of your html document

<SCRIPT LANGUAGE="JavaScript">
<!-- //Hide From Old Browsers

/* Do Not Remove the Following Line
   For more scripts visit http://www.w3courses.com
*/

//Change the following link to yours
var link = "http://www.w3courses.com";

Share

Create an Add to Favorite link using Javascript

You can create a link named Add to Favorites and when a user clicks on it, the link will prompt the user to add your site to their favorites. Use the following code to implement this solution:

<HTML>
<BODY>

<SCRIPT LANGUAGE="JavaScript">
<!-- //Hide From Old Browsers

/* Do Not Remove the Following Line
   For more scripts visit http://www.w3courses.com
*/

Share

Mouse Over Image Change Effect in JavaScript

Would you like to change an image when mouse is hoered over it? This is perfect for making a menu and have the images lightenup or darken when hovered over it.

First create a javamain.js javascript file with the following code

browserName=navigator.appName;
browserVer=parseInt(navigator.appVersion);

Share