0
votes

Is there a way to open a url in the current window of Firefox using Applescript? I figured out how to open a specified url using open location:

tell application "Firefox" to open location "http://duckduckgo.com"

This, however, opens it in a new tab. I searched online and found a work-around that uses System Events to highlight the address bar and enter the url with keystrokes, but it'd be nice to find a more elegant solution (and it makes me chuckle every time I watch the url being ghost-typed in).

I'm running Firefox 3.6.28, which is the newest version that will run on my ppc mac (10.4.11).

Thanks for any help!

2

2 Answers

0
votes

System Events is the best you will get for Firefox. You should use either Safari or Chrome.

0
votes

In the Applescript Dictionary (found in the File Menu > Open Dictionary > Firefox), you will find a Get URL ability for Firefox. I am running a slightly older version so I am not sure if this would work, but I was able to successfully run:

tell application "Firefox"
Get URL "http://duckduckgo.com"
end tell

This opened the listed URL in quotes inside the existing Firefox window.

You can see that there are other functions like OpenURL which will open the specified URL in a new window also which are listed in the Firefox Dictionary.