Do javascript in Tab 2

How do I send the following command to tab 2, if tab 2 is not the current tab?

do JavaScript "document.getElementById('signInbutton').onclick()" in document 1

Right now my script is using this to select the tab I need to perform the action in.

tell window 1 to set current tab to tab 2

In Snow leopard and safari 5.1 I can do this

tell application "Safari"
	do JavaScript "alert('hello world')" in tab 2 of window 1
end tell

Perfect.

Thank you!

1 more …

Is there a way of doing the same thing with this?

tell application "System Events"
	tell process "Safari"
		set theStatus to name of UI element 1 of UI element 3 of every row of table 1 of UI element 1 of scroll area 1 of group 1 of group 1 of group 4 of window 1
	end tell
end tell