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

  • SEARCH
  • Home
  • 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 7834161
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T13:04:51+00:00 2026-06-02T13:04:51+00:00

I have a Javascript function on my webpage that I’m displaying in a UIWebView:

  • 0

I have a Javascript function on my webpage that I’m displaying in a UIWebView:

$(document).ready(function() {
   // index to reference the next/prev display
var i = 0;
   // get the total number of display sections
   //    where the ID starts with "display_"
var len = $('div[id^="hl"]').length;


   // for next, increment the index, or reset to 0, and concatenate 
   //    it to "display_" and set it as the hash
$('#next').click(function() {
    ++i;
    window.location.hash = "hl" + i;
    return false;
});


   // for prev, if the index is 0, set it to the total length, then decrement
   //    it, concatenate it to "display_" and set it as the hash
$('#prev').click(function() {
    if (i > 1)
    --i;
    window.location.hash = "hl" + i;
    return false;
});

});

So what I need to do is simulate an anchor click when my UIButton is clicked:

- (IBAction)next:(id)sender {
    [animalDesciption stringByEvaluatingJavaScriptFromString:@"document.getElementById(\"next\").click();"];
}

But this doesn’t work!
It works great on an HTML page, just by clicking the anchor that has an id of “next”.

Any ideas why this won’t work when clicking the button?

BTW I am able to call a standard javascript function like myFunc() with my current setup, but it won’t do anything like this!

Any thoughts would be very appreciated!

  • 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-06-02T13:04:54+00:00Added an answer on June 2, 2026 at 1:04 pm

    You could implement javascript functions for next and previous and call that directly from your UIButton.

    var i = 0;
    
    function next() {
       ++i;
        window.location.hash = "hl" + i;
        return false;
    }
    
    function prev() {
       if (i > 1)
        --i;
        window.location.hash = "hl" + i;
        return false;
    }
    
    $(document).ready(function() {
       // get the total number of display sections   
       // where the ID starts with "display_"
       var len = $('div[id^="hl"]').length;
    
       $('#next').click(function() {
           next();
       });
    
       $('#prev').click(function() {
          prev():
       });
    
    });
    

    The call from your UIButton would be:

    - (IBAction)next:(id)sender {
        [animalDesciption stringByEvaluatingJavaScriptFromString:@"next()"];
    }
    

    By the way: I think you forgot to use len in the next() function to avoid stepping over the last display section.

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

Sidebar

Related Questions

I have a javascript function (class) that takes a function reference as one paremter.
I have a JavaScript function that loads a flash movie into a webpage div
I have some VBA code that opens a webpage, then calls a javascript function
I have found a javascript function that inverts colors on webpage: String javascript =
in .gsp file i have javaScript function <script type=text/javascript> function getCurrentItemNumber(){ return document.getElementById('item_itemNumber').innerHTML.substr(6); }
I have a javascript function that manipulates the DOM when it is called (adds
I have a javascript function (function1) that checks some global variables (can the user
I have a javascript function that calls a generic function to make an ajax
I have a javascript function that accepts a number and performs a mathematical operation
I have a header on my webpage that contains the some javascript for some

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.