4

I am creating a android app based on webview in which i need to display html like a ebook page wise, the reason i have to use webview is because i need a changing header accroding to content view this link while scrolling header changes http://jsfiddle.net/kd6Y4/10/show/ how can i paginate it please help me with the code here is jsfiddle link http://jsfiddle.net/kd6Y4/10/ js code am using to read header and add highlight to the ebook :-

$(window).scroll(function() {
  var winTop = $(this).scrollTop();
  var divs = $("div");

  var top = $.grep(divs, function(item) {
    return $(item).position().top <= winTop;
  });

  //var id=$(top).first().attr('id');
  var ll = $(top);

  $(top).each(function(i, item) {
    var total = ll.length - 1;

    if (total == i) {
      $("#finalvalue1").empty();
      document.title = $(item).attr("id");
    }
  });
});

function createListener1() {
  document.addEventListener(
    "click",
    function(event) {
      var element = event.target;
      if (element !== document.body) {
        if (element.className === "vs") {
          element.className = "highlight1";
        } else if (element.className === "highlight1") {
          element.className = "vs";
        }
      }
    },
    false
  );
}

function createListener2() {
  document.addEventListener(
    "click",
    function(event) {
      var element = event.target;
      if (element !== document.body) {
        if (element.className === "vs") {
          element.className = "highlight2";
        } else if (element.className === "highlight2") {
          element.className = "vs";
        }
      }
    },
    false
  );
}

function createListener3() {
  document.addEventListener(
    "click",
    function(event) {
      var element = event.target;
      if (element !== document.body) {
        if (element.className === "vs") {
          element.className = "highlight3";
        } else if (element.className === "highlight3") {
          element.className = "vs";
        }
      }
    },
    false
  );
}
n1stre
  • 5,856
  • 4
  • 20
  • 41

0 Answers0