Opening a webpage in the default browser?

Hi, I’m new to Applescripting and I mostly work on a PC. But right now I’m working on a cross-platform CD-ROM. I need a very basic Applescript which will open a webpage in the viewer’s web browser. I’ve tried

tell application "Internet Explorer"
   Activate
   OpenURL "http://www.mywebpage.com/"
end tell

Only I don’t want the script to specify which application (I want it to just choose the default webpage handler for the person’s Mac).

Can anyone help?

Thanks, Phyllis

Hi,
you have open location in Standard additions Dictionnary, so :


open location "http://www.mywebpage.com/"

will do your job.

Hm I’ve also tried

tell application "Finder"
   open location "http://www.webpage.com"
end tell

but got an error message on the CD with that one. I’m calling the Applescripts from Macromedia Flash. I have no trouble with Applescripts that open PDF files, just the webpage. I get the “Some data was the wrong type” error message. But perhaps I’ve screwed up somewhere other than the script itself…

I can alter my PDF-opening script to open an HTML file that redirects to the webpage I want, but that seems a redundant workaround.

Thanks, Phyllis

The Finder isn’t required. Try this: open location “http://www.webpage.com

– Rob

Just that line by itself? Okay will try. Gotta go borrow a Mac to test it. I’ll post again if no luck!

(It’s interesting trying to make a cross-platform CD while only having a PC.)

Thanks, Phyllis

Hi, I’ve tried using that line by itself. It works just fine! Except I have one problem: I only have a Mac OS 8.5 to write the scripts on. I tried using the script that I had written on OS 8. 5 on an OS X computer. It works, except that it causes the OS X to restart in classic mode (OS 9). Is there any way around that?

I guess maybe now I’m in the wrong forum for this question. I am trying to script in a pre-OS X version of Mac. I’m hoping that a script as basic as opening a webpage will work in OS X also. I know some of the people viewing my stuff will be using OS X.

But, as I said, it opens in classic OS 9. And so I don’t know what would happen if the user only had OS X on their computer. Is anyone out there running OS X only? If so, can you tell me if this script works on it (attachment in binhex)?

Thanks for the help!!!

Phyllis

It works fine on my OS X-only machine when run from Script Editor but when I launch the script it asks for classic. I don’t have classic so I don’t know how to overcome the issue.

– Rob

Weird. Guess I’ll give up on that one!

Funny thing is I have the other script that I use for opening PDF’s. It works fine in OS X (though I created it in OS 8.6). But if I replace a PDF with an HTML document, it switches to OS Classic. Strange.

Thanks for your testing help! Hey, any idea if a script created in OS X is backwards compatible? Like if you saved “open location…” as an application on OS X, would it work on OS 8.6? Maybe I can borrow an OS X at some point (so long as it’s backwards compatible).

Phyllis

Here’s a script (app) created in OS X. The complete code is:

open location "http://www.webpage.com"

http://home.woh.rr.com/rjj/downloads/open_location.sit

– Rob

Hey thanks for posting that! I just tried it on an OS 8.6, and it works fine. So I guess X is backwards-compatible on applescripts.

I heard once that scripts on OS X have a hidden extension of .app – I couldn’t figure out how to tell on the file. Do you know?

So now I just need to borrow an OS X… Thus far, I haven’t been able to find any place renting one but will keep trying.

Thanks again!
Phyllis

That’s good to know.

You can name a script application with or without the .app extension. The file that you downloaded did not have the extension.

Maybe you can visit an Apple Store or dealer and use one of theirs. :wink:

– Rob

Hi. Can you tell me how you saved that? Application, script, etc.? I managed to borrow an OS X for a while so want to try making some (that will hopefully be bacwards compatible).

Thanks, Phyllis

It was saved as an application without the .app extension.

– Rob