Make Safari Stop Loading

Is there some way to make Safari stop loading with out using system events?

And if not how do you do that with system events?

Mainly I want to be able to stop Safari without have to activate it.

Thanks

If you don’t care brute-forcing Safari, you can:

tell app "Safari" to set url of document 1 to ""

And a quick example w/ System Events:

tell application "System Events"
	tell process "Safari"
		--> if the reload/stop button is visible, you can use this without activating Safari
		click button "Stop" of window 1
		
		--> otherwise...
		set frontmost to true
		keystroke "." using command down
	end tell
end tell

Awesome.

Thank you very much.

That does exactly what I need it to do.