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.