JavaScript file to open browser with multiple tabs

Hello all, this is my first post and first Mac. On my PC I have a script, shown below, that I can click on to open multiple tabs within Internet Explorer.

var OpenTab = 0x1000;
var IE = new ActiveXObject("InternetExplorer.Application");
IE.Navigate2("http://www.yahoo.com/");
IE.Navigate2("http://cnn.com/", OpenTab);
IE.Visible = true;

Can anyone point out to me how to do this in the Mac world?

Thanks!

iMac, Mac OS X (10.6.2)

Posted on Dec 12, 2009 10:53 AM

Reply
6 replies

Dec 12, 2009 12:21 PM in response to kneedragger101

You can't use JavaScript to do this, nor do you need to. All you have to do is setup your Preferences correctly to open new links in Tabs. Then open two different tabs, one for each site.

Next, open a new tab and click on the icon to show all your Bookmarks. At the bottom left of that window, click the "+" sign to create a new folder and name it. Then click on the Bookmarks Bar icon in that window an drag that folder into the right side of that window, and check the Auto-Click box.

Now close that window, select one of the Tabs for those sites you want to open and drag the URL from the address bar over the folder you created on the Bookmarks Bar until you see the gree "+" sign and release it. Do the same for the other Tab and the other site.

From now on, when you start Safari, all you need to do is click once on that folder and those sites will open in their own Tab. It does sound more complicated than it is, but it works beautifully.

Dec 12, 2009 3:54 PM in response to Golden Shoes

I appreciate the tips, I know how to do this. What I want to do is have a link on my desktop that will open a browser instance with all the tabs that I choose. I don't want this to happen every time I open the browser. I only want this to happen when I click the JavaScript code file.

There must be some way to do this - it is SO easy in Windows and I do use JavaScript this exact way in Windows and I have a link in my task bar that I click each morning to check stuff like my bank account and cnn, etc.

Dec 12, 2009 4:39 PM in response to kneedragger101

Unless you have some outside program to execute the JavaScript file, you can't do this using that method. ActiveX is a Microsoft "technology" that is built into the core of Windows, and it's not the same as JavaScript. That's why your method works in Windows.

You might be able to accomplish this via AppleScript, but if so, I'm not versed in how; you'd have to post that specific question in the AppleScript forums.

Dec 13, 2009 9:38 AM in response to kneedragger101

In addition to jakudo's suggestion regarding the use of Automator, an AppleScript can be created using a series of *open location* commands. Simply replace the example urls in the script below with your desired urls. Copy the block of code and paste it into your AppleScript Editor, located in the Applications > Utilities folder (users of operating systems prior to Snow Leopard will find the Script Editor located in the Applications > AppleScript folder). From the AppleScript Editor's File menu choose Save As > File Format: application, and leave the Options unchecked.

+Example script:+

*tell application "Safari"*
activate
*if not (exists window 1) or name of window 1 is not "Untitled" then*
*make new document*
*end if*
*open location "http://www.apple.com/"*
*open location "http://www.macupdate.com/"*
*open location "http://www.macosxhints.com"*
*open location "http://www.macrumors.com"*
*end tell*

The saved AppleScript applet can be run from the dock or by double-clicking on its desktop icon. Note that Safari preferences should be set so that links from applications will open in a new tab. Good luck.

+The above script was tested in Mac OS 10.4.11. Leopard and Snow Leopard users' results may vary.+

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

JavaScript file to open browser with multiple tabs

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.