views:

40

answers:

2

I create a safari extension , but I don't kown how to add javascript code to safari extension?

+2  A: 

A Safari extension is almost entirely Javascript. That's a bit of an oversimplification, but what kind of extension have you created if there's no Javascript? You can write as much or as little JS as you like in any injected script or in a global HTML file. The details of where/when/how to use each of these is pretty well documented.

There's nothing particularly special about the nature of the Javascript that you can place in any of these files except that you do have access to a Safari-centric API. Otherwise, it's just the same old Javascript you'd write for the web with a few quirks of the framework itself. A lot of folks even include jQuery or other JS libraries to help, though they add more overhead than I'd recommend in most cases.

Rob Wilkerson
+1  A: 

I think you should read this first. Safari Extension Development Guide

JackieLi