Weird Firefox behaviour

Hi all,

I´m new to Mac and Applescript so I´m not sure what´s wrong in my script. I´ve already googled, but without result.

What I like to do: Open Firefox and go to a specific website

I tried following versions:

tell application "Firefox"
 launch
 activate
 Get URL "myurl.com"
end tell

This script opens Firefox but when I try this script the first time, always two windows are open (homesite and myurl), so I tried to use the front window or open the new url, but with the same result

tell application "Firefox"
 launch
 activate
 if window 1 exists then
   Get URL "myurl.com" inside window 1
  else
    Get URL "myurl.com"
  end if
end tell

I´m sure I´m making some stupid newbie fault, but I can´t find it in this mini script.

thx for replies

Chris

When I tried this:


tell application "Firefox"
     Get URL "myURL.com"
end tell

Firefox ignored my usual default page and just opened myURL.com.
If I launch or activate, I get my default page with it as you do.

Firefox’s dictionary is pretty minimal. :rolleyes:

I think the problem is that the Get URL command is processed while window 1 (your default page) is still being created, so it returns the URL in a new window.

I tried this:

property notLoaded : true

tell application "Firefox"
	launch
	activate
	repeat while notLoaded --loop to test for existence of window 1
		set theWindows to every window
		if (count of theWindows) > 0 then
			set targetWindow to first item of theWindows
			set notLoaded to false
		end if
	end repeat
	Get URL "http://www.apple.com" inside targetWindow
end tell

and apple.com loaded in a new tab in window 1.

Then I changed Firefox’s prefs to load links from other applications in the most recent window, and ran the script again; this time, my default page immediately switched to apple.com.