I’m experimenting with the following script to save the source code of an open Safari window and then save the code in PageSpinner and create a frameset of the document. (I am trying to get it eventually to have Safari create a frameset of the current window along with the selected link (when a link on the page is selected through a contextual menu))
I am new to Applescript and puzzled why I get an error for “paste document 1” when the paste works as long as I don’t include the last segment of code in the previous line
& "" marginwidth="1"></frameset>"
in setting the clipboard. Any suggestions why it won’t execute the paste command under these conditions?
Thanks in advance,
Brett
tell application "Safari"
activate
set current_doc to source of document 1
set current_url to URL of document 1
set the clipboard to current_doc
end tell
tell application "PageSpinner"
activate
set appll to "Macintosh HD:Users:Brett:Desktop:frametemp.html"
open file appll
select all document 1
paste document 1
save document 1 to file "Macintosh HD:Users:Brett:Desktop:frametemp.html"
close document 1 saving in "Macintosh HD:Users:Brett:Desktop:frametemp.html"
set appll2 to "Macintosh HD:Users:Brett:Desktop:frametemp2.html"
open file appll2
set the clipboard to "<frameset rows="50%, 50%" border="5"><frame src="file:///Users/Brett/Desktop/frametemp.html" marginwidth="1" target="2"><frame name="2" src="" & current_url & "" marginwidth="1"></frameset>"
paste document 1
save document 1 to file "Macintosh HD:Users:Brett:Desktop:frametemp2.html"
end tell
tell application "Safari"
activate
open file appll2
end tell