Results 1 to 3 of 3
  1. #1

    amarkon's Avatar
    Member Since
    Mar 21, 2012
    Location
    Eagan, MN
    Posts
    5
    Specs:
    Aluminum Unibody Macbook (Late 2008) 2.4 GHz Intel Core 2 Duo, 250GB HD, 6GB RAM, 10.8 Dev Preview
    Help with stringByEvaluatingJavaScriptFromString in UIWebView
    Can anyone tell me why the following code isn't working?

    - (void)viewDidLoad
    {
    [super viewDidLoad];

    NSString *website = @"http://www.rschooltoday.com/se3bin/clientgenie.cgi?schoolname=school1&statusFlag=goGe nie&geniesite=1145&myButton=g5plugin&db=g1145_b161 45";
    NSURL *url = [NSURL URLWithString:website];
    //NSURLRequest *requestUrl = [NSURLRequest requestWithURL:url];
    //[webview loadRequest:requestUrl];
    NSString *html = [webview stringByEvaluatingJavaScriptFromString:
    @"getElementById(content_well_div_)"];
    [self.webview loadHTMLString:html baseURL:url];
    }

    I'm trying to load just the central content of that teacher's page, but I don't have much experience with JS or HTML, this is just what I've been able to figure out from other forums and Wikipedia.

    Thanks in advance!!

  2. #2

    Mark FX's Avatar
    Member Since
    Aug 13, 2011
    Location
    West Sussex, UK
    Posts
    186
    Sorry to say it, but your code is a bit of a mess, firstly you need to use NSURLConnection, NSURLRequest, and NSURL class's to make it possible.

    Also I noticed you have commented out two of the above lines of code.

    //NSURLRequest *requestUrl = [NSURLRequest requestWithURL:url];
    //[webview loadRequest:requestUrl];
    So these two lines are doing nothing.

    I would reccommend you read the Apple documentation that deals with loading URL's.

    https://developer.apple.com/library/.../uid/10000165i

    Try reading this, and things will be a lot clearer for you.

    Regards Mark

  3. #3

    amarkon's Avatar
    Member Since
    Mar 21, 2012
    Location
    Eagan, MN
    Posts
    5
    Specs:
    Aluminum Unibody Macbook (Late 2008) 2.4 GHz Intel Core 2 Duo, 250GB HD, 6GB RAM, 10.8 Dev Preview
    Thanks. I just don't use JS or HTML often, much less WebViews.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Scrollbar in UIWebView
    By webherper in forum iOS Development
    Replies: 0
    Last Post: 05-06-2012, 09:01 PM
  2. iOS 5 UIWebView JavaScript Help
    By amarkon in forum iOS and Apps
    Replies: 0
    Last Post: 03-21-2012, 04:49 PM
  3. uiwebview problem
    By sagarshivam in forum iOS Development
    Replies: 9
    Last Post: 09-17-2011, 02:17 AM
  4. UIWebview query
    By sagarshivam in forum iOS Development
    Replies: 0
    Last Post: 09-06-2011, 01:53 PM
  5. Help, New, UIWebview not working
    By BenLynch2000 in forum iOS Development
    Replies: 2
    Last Post: 08-23-2011, 01:45 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •