Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7428989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T08:53:53+00:00 2026-05-29T08:53:53+00:00

I’ve a great problem. I must pass a variable of a javascript function into

  • 0

I’ve a great problem. I must pass a variable of a javascript function into an objective-C variable.
These are my code’s parts:

Javascript:

function abc(){
something...
}

Objective-C:

    myLabel.text = [webView stringByEvaluatingJavaScriptFromString:@"documentElement.textContent"];

The javascript code prints to video a number that I want use in my Objective-C code but with this nothing appears, instead using this code:

myLabel.text = [webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.textContent"];

It pass the value that I want and the entire code of the javascript function!

Please some advice…. Thanks at all!!!

`

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T08:53:54+00:00Added an answer on May 29, 2026 at 8:53 am

    You wan to call the function, not just refer to it:

    myLabel.text = [webView stringByEvaluatingJavaScriptFromString:@"document.documentElement.textContent()"];
    

    the key bit is at the end:

    ...documentElement.textContent()"];
    //                            ^^
    

    Since JavaScript functions are first-class objects, when you do:

    x = functionName;
    

    …x receives a reference to the function. In your case, since the UIWebView then coerces it to a string, you end up calling toString on the function, which on most JavaScript implementations gives you the code of the function (although this is not specified by any standard).

    To actually call a function, you put parentheses after it (with nothing in them, if there are no arguments you need to pass; or with arguments in them if you do), e.g.:

    x = functionName();
    

    Disclosure: I know nothing about iOS development, Objective-C, or UIWebView, but I was able to quickly find the stringByEvaluatingJavaScriptFromString function you were using, and then confirmed via this page that the string after the @ needs to be valid JavaScript code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am currently running into a problem where an element is coming back from
I used javascript for loading a picture on my website depending on which small
this is what i have right now Drawing an RSS feed into the php,
I am reading a book about Javascript and jQuery and using one of the
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.