URLs
Scott Rossi
scott at tactilemedia.com
Sun Mar 17 12:34:00 EST 2002
Recently, Shari wrote:
> This is the final result of a universal handler for URLs.
> ...
> Improvement suggestions are welcome. And if anybody knows a way to
> avoid using Applescript (without reverting to XCMDs), that would be
> most welcome!
Shari:
I think you'll find you can't rely on GURLGURL any more than you can rely on
AppleScript. Therefore, you might consider a multi-stage approach in your
handler, rather than relying on a single mechanism to launch URLs on
different Mac system versions. In other words:
try option 1
if option 1 fails, try option 2
etc
So your script could try different approaches until one works:
if (the platform) is "MacOS" then
put "open location" && quote & tURL & quote into s
do s as AppleScript
if the result is not empty then \
send tUrl to program "Finder" with "GURLGURL"
Also, I can tell you in "real world" launch implementations, the launch
command is not foolproof. The "GURLGURL" technique can fail on MacOS, and
we've found in Windows testing that launching fails with 3rd party browser
packages, such as EarthLink's browser and AOL's. The goofy thing is these
browsers are repackaged versions of IE, and yet they refuse to launch using
the same mechanisms.
The one way I've found to accommodate this is to use a "brute force" option
for launching that writes a URL into a simple HTML document on the user's
drive and launches the URL from this document. It's not pretty, but it
works, and we use this in both Mac and Windows launch scripts.
function createHTML tURL
put \
"<html>" & return &\
"<head>" & return &\
"<meta http-equiv=" & quote & "Refresh" & quote && "content=" &\
quote & "0; URL=" & tURL & quote & ">" & return &\
"<title>Launcher</title>" & return &\
"</head>" & return &\
"<body>" & return &\
"<center>" & return &\
"<BR><BR><BR>" & return &\
"Loading URL. One moment please..." & return &\
"</center>" & return &\
"</body>" & return &\
"</html>" into tCode
return tCode
end createHTML
The document created by this function is written to the temp directory on
Windows and or Preferences folder on MacOS. It is then launched using the
open file command available in the Externals Collection.
Finally, you might add error notification at the end of your handlers to
alert the user (and yourself) that launching failed for whatever reason.
This might make it more clear if the launch action fails.
FWIW,
Scott Rossi
Creative Director
Tactile Media, Multimedia & Design
Email: scott at tactilemedia.com
Web: www.tactilemedia.com
More information about the metacard
mailing list