Problem with applescript

I am pretty new to applescript… I just tried this:


	tell application "DEVONagent"
		if not (exists browser 1) then error "No browser windows are open."
		set this_browser to browser 1
		set u to (URL of this_browser) & ¬
			"&title=" & (name of this_browser)
		
		set target_url to "http://del.icio.us/dekay?v=2&url=" & u
		open URL target_url
	end tell

Why doesn’t the URL open in DevonAgent? When I check the output in ScriptEditor and copy/paste the URL to DA it works, same if I open the URL in Firefox with


	tell application "Firefox"
		activate
		OpenURL target_url
	end tell

Is there a way to summarize a web page in DA via AppleScript?

thx,

Dan

The open URL command requires a correct URL using escapes for non-ascii characters. But this script should work:


tell application "DEVONagent"
	if not (exists browser 1) then error "No browser windows are open."
	set theParams to do JavaScript "'&url='+escape(document.location)+'&title='+escape(document.title);" in browser 1
	open URL "http://del.icio.us/dekay?v=2" & theParams
end tell

Thanks… tricksy javascript in applescript :wink:

Just realized I need to pop this thread up again:

As posted above the script doesn’t work all the time, with some URLs it is reproducible.

e.g. zenhabits.net/2007/05/beginners- … o-cycling/

Any ideas?

Other than:


try
	tell application "DEVONagent"
		if not (exists browser 1) then error "No browser windows are open."
		set this_browser to browser 1
		set this_URL to the URL of this_browser
	end tell
	
	tell application "Firefox"
		activate
		OpenURL this_URL
	end tell
end try

The JavaScript code I’ve posted above is missing in your script (URLs have to be escaped too)

Christian, I do have the javascripted & escaped code in my script – which is not working all the time. The other script is just my way to open the current URL in Firefox…

:question:

The next release will improve the compatibility to escape codes created by JavaScript and then this should always work.