background preloader

Javascript - WYSIWYG - iOS dev

Facebook Twitter

WebKit Objective-C Programming Guide: Using JavaScript From Objective-C. The web scripting capabilities of the WebKit permit you to access JavaScript attributes and call JavaScript functions from your Cocoa Objective-C applications.

WebKit Objective-C Programming Guide: Using JavaScript From Objective-C

Refer to WebKit DOM Programming Topics if you want to access the Objective-C API from JavaScript. JavaScript objects are represented by instances of WebScriptObject in Objective-C. The API uses instances of WebScriptObject to wrap script objects passed from the scripting environment to Objective-C. You can use the methods of this class to call JavaScript functions and get/set properties of the JavaScript environment. You should not create WebScriptObject instances explicitly. Method parameters must be objects or basic data types like int and float.

Let’s look at a couple of examples. JavaScript makes it easy to access the attributes of a web page’s window. Rich Text Editing : A Simple Start (Part 1) Welcome to part one of the iOS 5 Rich Text Editing Series.

Rich Text Editing : A Simple Start (Part 1)

In this series of iOS/html text edit tutorials we’ll be looking at creating a simple Rich Text Editor which you can easily implement in your own apps. This tutorial is part of a series: Rich Text Editing : Validation (Part 2) Previous in the series: - Rich Text Editing : A Simple Start (Part 1) This tutorial is part of a series: Rich Text Editing : A Simple Start (Part 1)

Rich Text Editing : Validation (Part 2)

Rich Text Editing : Highlighting and UIMenuController (Part 3) Rich Text Editing : Fonts (Part 4) This tutorial is part of a series:

Rich Text Editing : Fonts (Part 4)

Rich Text Editing : Undo and Redo (Part 5) This tutorial is part of a series: Rich Text Editing : A Simple Start (Part 1) Rich Text Editing : Validation (Part 2) Rich Text Editing : Highlighting and UIMenuController (Part 3) Rich Text Editing : Fonts (Part 4)

Rich Text Editing : Undo and Redo (Part 5)

Rich Text Editing : Inserting Images (Part 6) This tutorial is part of a series: Rich Text Editing : A Simple Start (Part 1) Rich Text Editing : Validation (Part 2)

Rich Text Editing : Inserting Images (Part 6)

Rich Text Editing : Draggable Images (Part 7) ContentEditable UIWebView. ExecCommand method (document, TextRange, ...) JavaScript. Browser support: Allows running commands on certain objects.

execCommand method (document, TextRange, ...) JavaScript

The execCommand is one of the root methods of the rich-text editing feature of browsers. The execCommand method works differently in different browsers, the commands are only executable for editable elements in Firefox, Google Chrome and Safari, while in Internet Explorer and Opera they can be used in editable and non-editable elements also. The code generated by the execCommand method is different in browsers. Internet Explorer uses HTML tags, Firefox, Google Chrome and Safari generate inline styles and Opera sometimes uses HTML tags, sometimes styles. For example, if the 'bold' command is executed on a non-bold text, Internet Explorer and Opera generate a strong element around it, Firefox, Google Chrome and Safari generate a span element around it and set the fontWeight style property of the span element to 'bold'. Use the queryCommandSupported method to detect whether a command is supported by the execCommand method. Input commande list set for outputCommand method.

On output of execCommand. UIWebView secrets - part3 - How to properly call ObjectiveC from Javascript - Techno Barje. Let’s change the subject: this time no more talks about memory but always on UIWebView component.

UIWebView secrets - part3 - How to properly call ObjectiveC from Javascript - Techno Barje

When we use this component for something else than just displaying webpages, like building UI with HTML, Javascript, … We often want to call Javascript functions from objective C and the opposite. Call Javascript function from Objective-C: The first move is easily done with the following piece of code: // In your Javascript files: function myJavascriptFunction () { // Do whatever your want!

} // ----------------------------------- // And in your Objective-C code: // Call Javascript function from Objective-C: [webview stringByEvaluatingJavaScriptFromString:@"myJavascriptFunction()"]; Call Objective-C function from Javascript: But calling objective-c from a Javascript function is not easy as Iphone SDK doesn’t offer any native way to do this!

(a very extremely plenty much advised practice!) What’s wrong with UIWebViewDelegate, shouldStartLoadWithRequest and location change ?