Re: Safari.app and saving frontmost document
Re: Safari.app and saving frontmost document
- Subject: Re: Safari.app and saving frontmost document
- From: Andrew Oliver <email@hidden>
- Date: Fri, 07 May 2004 13:42:34 -0700
Safari's 'save' command requires an alias reference in which to save the
file.
'open for access' on the other hand, is the standard command for direct file
access when you want your script to read or write data. In this case you
want Safari to do it, so you don't need to explicitly open the file first.
So either pass Safari an alias in which to save the file, and don't use
'open for access', or use open for access and pass in the data directly, but
don't use both:
tell application "Safari"
set dataToSave to (source of document 1) as text
end tell
set theFile to open for access file "Macintosh HD:dump:5.html" with write
permission
write dataToSave to theFile starting at 0
close access theFile
On 5/7/04 1:07 PM, "Jacco Rens" <email@hidden> wrote:
>
Hi list-members,
>
>
Can someone show me the way to save an safari window, just like we do
>
with command + s ? The following doesn't work, although logic says it
>
should:
>
>
tell application "Safari"
>
set theFile to (path to desktop as text) & "mytextfile.txt"
>
try
>
set openedFile to open for access theFile with write permission
>
save document 1 in openedFile
>
close access openedFile
>
end try
>
end tell
>
>
I tried saving the source, but that returns unusable (Unicode?) output.
>
>
>
best,
>
jacco rens,
>
Netherlands
>
_______________________________________________
>
applescript-users mailing list | email@hidden
>
Help/Unsubscribe/Archives:
>
http://www.lists.apple.com/mailman/listinfo/applescript-users
>
Do not post admin requests to the list. They will be ignored.
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.