Comments (4)
You can do [myElement valueForKey:@"innerHTML"]
or if you want to do it neatly, you might be able to define a protocol with a -(NSString*)innerHTML;
method and cast the GAScriptObject to it. Then you can probably use myElement.innerHTML
(without actually coding anything)
from gajavascript.
Apart from that I think you should ask this question on a site like StackOverflow since this is not an "issue"
from gajavascript.
In your code snippet above, [document getElementsByClassName:@"div"]
would return an HTML collection of elements, so you'll have to do something like this:
#import "GAScriptMethodSignatures.h" // for "[length]" and "[item:]"
id document = [webView documentJS];
id myElements = [document getElementsByTagName(@"div")];
for (NSInteger i = 0; i < [myElements length]; ++i)
{
id anElement = [myElements item:i];
NSString *innerHTML = [anElement valueForKey:@"innerHTML"];
}
If you want to get all the DIVs filtering by an attribute, you can use [document querySelectorAll:@"div[attr=val]"]
. Make sure to try out the query in the Safari Web Inspector first, since it might take some tweaks to get what you want. "querySelectorAll" is really handy and gives jQuery-like access to elements in a single method call.
from gajavascript.
Experimenting with this code helped me find a bug in the NSFastEnumeration implementation inside GAScriptObject. Cool.
from gajavascript.
Related Issues (14)
- Need to add "--all_load & --ObjC" linker flags HOT 3
- NSFastEnumeration broken when the object has more than 16 properties
- Refactor library to use ARC
- Block callbacks not invoked
- gajavascript_frame is not completely hidden
- Update WebView Explorer Demo
- Block callback args corrupted when arrays are passed HOT 1
- Readme.MD is outdated HOT 1
- Multiple UIWebView / GAScriptEngine & Caching Issues HOT 3
- Weird issue with GAJavascript.performSelector JS HOT 2
- Will GAJavascript work with UIWebView inside UITableViewCell? HOT 2
- Create instances of ObjC objects from JS HOT 3
- Basic to integrate
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gajavascript.