Safari applications seem to have a different scope between your target html page and main.js end script. This means that if you wish to inject a control onto your screen which calls a function in your main.js script it will not work because the two can’t see each other.
Since the introduction of iOS4, blocks have become very prevalent in the Cocoa framework as a quick and non messy way of implementing a ‘callback’. Blocks can be passed around just like any other variable. They are most used in UIView animations.
Harnessing the power and simplicity of blocks is something that I have been doing a lot more since iOS4, turning old fashioned protocol delegates into blocks where it makes sense.