Error handling Safari windows

In Camino dictionary, there is “browser window” which separates itself from other windows (like “downloads” window). How to refer to browser window in Safari (not any other window like “Downloads” window, “Activity” window) ?
I am currently using this:

tell application "Safari"
	set theURL to "http://www.google.com"
	my makenewurl(theURL)
end tell
on makenewurl(x)
	tell application "Safari"
		if name of window 1 is not "Downloads" then
			tell window 1 to make new tab with properties {URL:x}
		else
			if name of window 2 is not "Downloads" then
				tell window 2 to make new tab with properties {URL:x}
			end if
		end if
	end tell
end makenewurl

Hi,

is this a way?


tell application "Safari" to set browserWindow to (get 1st window whose its document is document 1)

As much as I understand, no.

tell application "Safari" to set browserWindow to (get 1st window whose its document is document 1)
tell browserWindow
	get name of document 1
end tell

If the above script is run after keeping “Downloads” window in front then I get an error,

I think this must be the correct way:


tell application "Safari"
	set browserWindow to (get 1st window whose its document is not missing value)
end tell

Secondly, though UI browser Screen Reader shows “Activity” window as “dialog 1 (Window 1)”, script editor does not seem to treat it as a window.

Try this, Chris:

tell app "Safari"
if (count windows) > 1 then
set browserWindow to (first window whose name is not "Downloads")
end if
end tell

Jim Neumann
BLUEFROG