Home > Archive > AppleScript > May 2004 > Open at URL in a (default) browser window and take focus
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Open at URL in a (default) browser window and take focus
|
|
| Mark Anderson 2004-05-13, 8:30 pm |
| As a 3-rd party 'help' measure for an app I sue, I want a script that
will open the users Browsers window to show a passed URL or Google
query and make the window take focus - i.e be in front.
IOW they click the script link and when called it pops an
IE/Safari/whatever app window and displays www.domain.com/page.html
making the browser the front window - or al least in front of the
calling app. Oh and the window should be a new one so as not to disturb
any windows the user may already have open
I've done this in Windoze but I'm not sure where to start with the
default htm/html handler which is what I do in the 'other' OS -
basically tell the OS "open this page".
TIA
Mark
| |
| Jerry Kindall 2004-05-13, 9:30 pm |
| In article <c80vq0$c06$1$8302bc10@news.demon.co.uk>, Mark Anderson
<mark@notmeyeardley.demon.co.uk> wrote:
> As a 3-rd party 'help' measure for an app I sue, I want a script that
> will open the users Browsers window to show a passed URL or Google
> query and make the window take focus - i.e be in front.
>
> IOW they click the script link and when called it pops an
> IE/Safari/whatever app window and displays www.domain.com/page.html
> making the browser the front window - or al least in front of the
> calling app. Oh and the window should be a new one so as not to disturb
> any windows the user may already have open
>
> I've done this in Windoze but I'm not sure where to start with the
> default htm/html handler which is what I do in the 'other' OS -
> basically tell the OS "open this page".
open location "http://foo.bar.com/"
There's no way to guarantee that the URL opens in a new window, but
that's okay, because the last thing most users want is a bunch of
unrequested browser windows open.
--
Jerry Kindall, Seattle, WA <http://www.jerrykindall.com/>
Send only plain text messages under 32K to the Reply-To address.
This mailbox is filtered aggressively to thwart spam and viruses.
| |
| Mark Anderson 2004-05-14, 6:30 am |
| > open location "http://foo.bar.com/"
Thanks - works a treat. I've tracked this to Standard Additions (SA). I
understand that generally you use the call to SA features without a tell
block, but this does make me wonder how you deliberately 'tell' SA where
a dictionary clash - i.e. you are in a tell block for an app that has
its own "open location syntax?".
> There's no way to guarantee that the URL opens in a new window, but
> that's okay, because the last thing most users want is a bunch of
> unrequested browser windows open.
In general I'd agree, but in this case it is the deliberately stated
purpose of a script which can only be installed/run by the user. If they
don't want this function then they don't install it!
Anyway, thanks again.
Regards
Mark
| |
| Patrick Stadelmann 2004-05-14, 6:30 am |
| In article <c822j7$cdm$1$8300dec7@news.demon.co.uk>,
"Mark Anderson" <mark@notmeyeardley.demon.co.uk> wrote:
>
> Thanks - works a treat. I've tracked this to Standard Additions (SA). I
> understand that generally you use the call to SA features without a tell
> block, but this does make me wonder how you deliberately 'tell' SA where
> a dictionary clash - i.e. you are in a tell block for an app that has
> its own "open location syntax?".
You should not call SA from within a tell block. If you're inside one,
use "tell me to ..."
Patrick
--
Patrick Stadelmann <Patrick.Stadelmann@unine.ch>
| |
| Michelle Steiner 2004-05-14, 1:30 pm |
| In article <c822j7$cdm$1$8300dec7@news.demon.co.uk>,
"Mark Anderson" <mark@notmeyeardley.demon.co.uk> wrote:
>
> Thanks - works a treat. I've tracked this to Standard Additions (SA).
> I understand that generally you use the call to SA features without
> a tell block, but this does make me wonder how you deliberately
> 'tell' SA where a dictionary clash - i.e. you are in a tell block for
> an app that has its own "open location syntax?".
"tell me" might work. "me" refers to the script itself.
If "tell me" doesn't work, do it outside of the tell block. Use a
subroutine if necessary.
--
Stop Mad Cowboy Disease: Vote for John Kerry.
| |
| Jerry Kindall 2004-05-14, 5:30 pm |
| In article <michelle-EB2E27.09571414052004@news.west.cox.net>, Michelle
Steiner <michelle@michelle.org> wrote:
> In article <c822j7$cdm$1$8300dec7@news.demon.co.uk>,
> "Mark Anderson" <mark@notmeyeardley.demon.co.uk> wrote:
>
>
> "tell me" might work. "me" refers to the script itself.
>
> If "tell me" doesn't work, do it outside of the tell block. Use a
> subroutine if necessary.
"tell me to open location" or "my open location" will work. You could
put it in a subroutine, but you'd still need "tell me" or "my..." to
call it.
--
Jerry Kindall, Seattle, WA <http://www.jerrykindall.com/>
Send only plain text messages under 32K to the Reply-To address.
This mailbox is filtered aggressively to thwart spam and viruses.
| |
| Gnarlodious 2004-05-14, 5:30 pm |
| Entity Jerry Kindall spoke thus:
>
> "tell me to open location" or "my open location" will work. You could
> put it in a subroutine, but you'd still need "tell me" or "my..." to
> call it.
Should be bulletproof:
try
set defaultBrowser to word -1 of ¬
(do shell script "defaults read com.apple.LaunchServices | grep -C5
E:html | grep -w LSBundleSignature")
set {text:defaultBrowser} to (text of defaultBrowser) as text
tell application "Finder" to set the defaultBrowser to the name of
application file id defaultBrowser as text
end try
tell application defaultBrowser
activate
open location "http://www.Gnarlodious.com/SantaFe/Tour.php"
end tell
-- Gnarlie
| |
| Mark Anderson 2004-05-14, 7:30 pm |
| Wow, thanks everyone.
Kind of you to share your knowledge. This is just the kind of basic
stuff the 'experts' who write AS books and tutorials 'forget' to
mention - most seem unaware of the me/my construct! Honourable exception
to Matt Neuberg's book which is not only informative but atypically
readable for a software book.
BTW, I should note that Jerry's solution works just fine in the original
scenario and is in use already.
Regards
Mark
|
|
|
|
|