• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Help on Checking an applications dictionary for a command
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Help on Checking an applications dictionary for a command


  • Subject: Re: Help on Checking an applications dictionary for a command
  • From: Adam Wuellner <email@hidden>
  • Date: Fri, 24 Jun 2005 09:49:47 -0500

On 6/24/05, David Siberry <email@hidden> wrote:
> Hi thank you for your help, it has been greatly appreciated.

Glad to have helped.

> However it works for Safari, but when I try using the script with
> Internet Explorer the script fails and returns false.
>
> Note..
> Whe I runt the script with "tell application "Safari"" Safari opens in
> order to run the script. However when the script is changed to work on
> Internet Explorer. Internet Explorer does not open.
>
> Can you help?
>
> Cheers
>
> David
>
> Here is the script
>
> set canDoScriptFlag to 0
> set canDoJavaScriptFlag to 0
>
> try
>         run script "tell application \"Internet Explorer\"
>  do script  \"window.name\" in document 1
>  end tell"
>         display dialog "do JavaScript Script worked"
>         set canDoScriptFlag to 1
>
> on error
>         display dialog "do script broke"
>         set canDoScriptFlag to 0
>
> end try
>
> try
>         run script "tell application \"Internet Explorer\"
>  do JavaScript  \"window.name\" in document 1
>  end tell"
>         display dialog "do JavaScript Script worked"
>         set canDoJavaScriptFlag to 1
>
> on error
>         display dialog "do JavaScript broke"
>         set canDoJavaScriptFlag to 0
>
> end try
>
> if (canDoScriptFlag is equal to 1 or canDoJavaScriptFlag is equal to 1) then
>         return true
> else
>         return false
> end if

The problem (to my eyes anyway) is that neither of the attempted
script commands are valid.

In Internet Explorer (5.2.3) the command is 'do script STRING [window
INTEGER]'.  The window parameter specifies which window to run the
script in, and is optional.

So, you can test for a Safari-like dictionary with your current do
JavaScript string:
run script "tell application \"BrowserName\" to do JavaScript
\"some.javascript.code\" in document 1"

But to test for an IE-like dictionary, you'll need use the correct syntax:
run script "tell application \"BrowserName\" to do script
\"some.javascript.code\""

I still think this is a poor general solution to discovering how to
execute javascript code from appliscript for an unknown target
browser.  It may work fine to determine whether either of the two
known forms will compile (compile, not necessarily produce the
expected results).

HTH,

Adam

PS - Please cc: the list with any responses.
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Help on Checking an applications dictionary for a command (From: David Siberry <email@hidden>)
 >Re: Help on Checking an applications dictionary for a command (From: Adam Wuellner <email@hidden>)

  • Prev by Date: Re: Apps for Querying MSSql with AppleScript
  • Next by Date: Re: Why is the Finder not recordable?
  • Previous by thread: Re: Help on Checking an applications dictionary for a command
  • Next by thread: Closing a window
  • Index(es):
    • Date
    • Thread