Launching a browser with an URL
Shari
gypsyware at earthlink.net
Thu Oct 24 15:06:01 EDT 2002
Here's my latest solution:
tUrl is the URL or email address
on goURL
global tURL
if tUrl is empty then
exit goURL
end if
if tURL contains "@" then put "mailto:" before tURL
if (the platform) is "MacOS" then
try
put "open location" && quote & tURL & quote into s
do s as AppleScript
catch theError
# only implements if there was an error
end try
if theError is empty then
put empty into tUrl
exit goUrl
else
put empty into theError
try
send tUrl to program "Finder" with "GURLGURL"
catch theError
# only implements if there was an error
end try
end if
else if (the platform) is "Win32" then
try
set the hideConsoleWindows to true
put empty into theTitle
if "NT" is in the systemVersion then
set the shellCommand to "cmd.exe"
put quote & quote into theTitle
end if
get shell("start" && theTitle && tURL)
catch theError
# only implements if there was an error
end try
if theError is empty then
put empty into tUrl
exit goUrl
else
put empty into theError
try
local intApp
local EXE_off
put
queryRegistry("hkey_local_machine\software\classes\http\shell\open\command\")
into intApp
if char 1 of intApp is quote then clear char 1 of intApp #
strip leading quote
put offset("EXE",intApp) into EXE_off
put char 1 to (EXE_off+2) of intApp into intApp
launch tURL with intApp
catch theError
# only implements if there was an error
end try
end if
if theError is empty then
put empty into tUrl
exit goUrl
else
put empty into theError
try
put word 1 to -2 of
queryRegistry("HKEY_LOCAL_MACHINE\Software\Classes\http\shell\open\command\")
into tBrowserPath
launch (tBrowserPath && tURL)
catch theError
# only implements if there was an error
end try
end if
end if
if theError is empty then # succeeded
put empty into tUrl
exit goUrl
else # failed
put tUrl into fld "temp"
select line 1 of fld "temp"
copy
if "@" is in tUrl then
answer "Blackjack Gold was unable to send us an email. You can
send us an" && \
"email as you normally would. The email address" && \
"is:" & return & return & tUrl & return & return & "It is
ready to paste it into your email program."
else
answer "Blackjack Gold was unable to take you to the website.
You can log on to" && \
"the internet and go there yourself. The URL for the" && \
"website is:" & return & return & tUrl & return & return &
"It is ready to paste it into your" && \
"internet browser."
end if
end if
put empty into tUrl
end goURL
--
--Shareware Games for the Mac--
http://www.gypsyware.com
More information about the metacard
mailing list