March 5, 2004

Cool JavaScript code snippet

If you have a set of websites that you like to check on a regular basis, this little snippet of JavaScript can automate opening the websites for you. You build an array of URLs in the format: bq. ,"http://www.your-url.com" and insert them into the code. You then save the code as something.html and put a shortcut to that file on your desktop. When you doubleclick it, it will open each of the URLs in a seperate window or copy of your browser. To see the code, click on the Continue reading "Cool JavaScript snippet" link below. PLEASE NOTE: In order for this to display and not be treated as regular HTML code, I replaced all of the angle-open and angle-closed characters (the ones located above the , and the . on your keyboards) with the square-bracket-open and closed characters (these [ ] ). To make the code work properly, you will need to change them back again... [html] [head] [script language="JavaScript"] [!-- urls = new Array("http://www.synthstuff.com/mt/" ,"http://www.brownsnout.com/" add more links here... ) function news() { for (i = 0; i [ urls.length; i++) { if ((i + 1) == urls.length) { location.href = urls[i]; } else { window.open(urls[i]); } } } // --] [/script] [/head] [body onload="news()"][/body] [/html] Posted by DaveH at March 5, 2004 4:32 PM