Trouble scripting a Safari "stop loading" action with System Events

Hi,

Been trying to write a script a handler which can be called
to tell Safari to stop loading a web page. (I am parsing
source code from web pages, so as soon as the source
is downloaded I don’t need Safari to build the page,
and I don’t want Safari to get hung up trying start
playing songs or animations or whatever.)

I downloaded the following code from this board,
and several users remarked that it worked. But it
doesn’t seem to work for me:

[code]

on stopSafari()
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
end tell
end tell
end stopSafari[/code]
Problem is two-fold:

  1. It either seems to do nothing

or

  1. it throws a “NSReceiverEvaluationScriptError: 4” error.

I have checked to make sure that “enable access for assistive devices”
is turned on

Any suggestions would be appreciated. Thanks.

-Jason

Haha! That definitely does the trick in 10.4. Unfortunately I have two machines, one of
which runs 10.3.9… Any body with any ideas for the old skool OS?

Also, I am noticing one other potential problem is a window popping up to let
me know that i don’t have the appropriate plug in. That seem to hold up the
entire process. Any ideas?

Thanks tons - @Large