Code Comments

Programming Forum and web based access to our favorite programming groups.
For Programmers: Free Programming Magazines | New: Database administration forum
Registration is free! Edit your profileCalendarFind other membersFrequently Asked QuestionsSearch -> 
Post New Thread











Thread
Author

Open at URL in a (default) browser window and take focus
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



Report this thread to moderator Post Follow-up to this message
Old Post
Mark Anderson
05-14-04 01:30 AM


Re: Open at URL in a (default) browser window and take focus
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.

Report this thread to moderator Post Follow-up to this message
Old Post
Jerry Kindall
05-14-04 02:30 AM


Re: Open at URL in a (default) browser window and take focus
> 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



Report this thread to moderator Post Follow-up to this message
Old Post
Mark Anderson
05-14-04 11:30 AM


Re: Open at URL in a (default) browser window and take focus
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>

Report this thread to moderator Post Follow-up to this message
Old Post
Patrick Stadelmann
05-14-04 11:30 AM


Re: Open at URL in a (default) browser window and take focus
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.

Report this thread to moderator Post Follow-up to this message
Old Post
Michelle Steiner
05-14-04 06:30 PM


Re: Open at URL in a (default) browser window and take focus
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.

Report this thread to moderator Post Follow-up to this message
Old Post
Jerry Kindall
05-14-04 10:30 PM


Re: Open at URL in a (default) browser window and take focus
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


Report this thread to moderator Post Follow-up to this message
Old Post
Gnarlodious
05-14-04 10:30 PM


Re: Open at URL in a (default) browser window and take focus
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






Report this thread to moderator Post Follow-up to this message
Old Post
Mark Anderson
05-15-04 12:30 AM


Sponsored Links




Last Thread Next Thread Next
Search this forum -> 
Post New Thread

AppleScript archive

Show a Printable Version Send to friend Email This Page to Someone! subscribe to this thread Receive updates to this thread
Computer Consultants
Programming Jobs
Visual Basic Controls
SQL Server Programming
Webservices
Java Security
Visual Studio
C# Programming
Visual J++
Software engineering
Open source Software
Perl Programming
PHP Programming
ASP Programming
ASP .NET Programming
Visual Basic Programming
Windows Scripting Host
Java Programming
Java Help
Java Beans
VBScript
Cobol
MAC Applications
Unix Programming
Forum Jump:
All times are GMT. The time now is 06:04 PM.

 
Free MCSE Braindumps | Real Estate Topics

Programming forum archive

Copyrights CodeComments.com 2004 - 2006

Powered by vBulletin Copyright 2000-2006 Jelsoft Enterprises Limited.