• 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
Checking an applications dictionary for a command
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Checking an applications dictionary for a command


  • Subject: Checking an applications dictionary for a command
  • From: David Siberry <email@hidden>
  • Date: Mon, 20 Jun 2005 16:27:51 +0100

Hi,

I am trying to write an apple script to check to see if a web browser
supports JavaScript. Its part of a browser detection application i am
writing.

The approach I am taking is this:

I want to use a try statement because depending on what your default
browser is depends which command you use. E.g. if your web browser is
Safari then the function call is "do JavaScript", if its Internet
Explorer then its "do script".

However, I want to create one script which will check the dictionary
of the multiple browsers if installed on your machine and try and call
"do script" if the try fails return false then call "do JavaScript".
If the command is found then return true.

For the "tell application "Safari" for example, the name of the
browser will be dynamic and passed in as a parameter from my C
program. This way I can keep the script generic and reusable.

However I am finding that when I compile if the "do script" or "do
JavaScript" is not in the given applications dictionary, then the
script will not compile.

The script I have written is:

tell application "Safari"

       try
               do script "window.name" (* simple dummy script to test with*)
               if (do script) then
                       return true
               else
                       return false
               end if
       end try

       try
               do JavaScript "window.name" (* simple dummy script to test with*)
               if (do JavaScript) then
                       return true
               else
                       return false
               end if
       end try

end tell

Cheers

David
 _______________________________________________
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

  • Prev by Date: Re: Open .term Files in 10.3
  • Next by Date: Some TextEdit Questions
  • Previous by thread: Some TextEdit Questions
  • Next by thread: different version of excel - script for getting a workbook open in a specific version
  • Index(es):
    • Date
    • Thread