How to tell if the page displayed in the Browser widget has scrolled

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to tell if the page displayed in the Browser widget has scrolled

Pi Digital via use-livecode
Is there a way (are you there Hermann?) of telling if a page being displayed in a browser widget has been scrolled down at all.

It doesn't seem there are any widget properties for this.

Hermann's solution to changing the font size was I think in effect injecting a javascript function/setting in the displayed document.

Is there a similar bit of code that can ask for the window scroll AND return an answer?

e.g. in pseudo pseudo code
 do "this function which reports the vertical scroll of the browser" in widget "browser" and put the answer into tBVScroll

Then, depending on whether  tBVScroll is 0 or not I can do other things to the controls around the browser.


James



_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode
Reply | Threaded
Open this post in threaded view
|

Re: How to tell if the page displayed in the Browser widget has scrolled

Pi Digital via use-livecode
The following works for me.

Write this code into a variable or a field:

window.onscroll = function() {
if (window.innerHeight + window.pageYOffset >=
document.body.offsetHeight) liveCode.jsNotify('I am at the bottom');
};

(a) Then script:
do <variableOrField> in widget "browser" if you can't control the htmltext.

or

(b) If you can control the htmltext then add the code above enclosed in
<script></script> tags right before </body>.

Set (another) javascriptHandler of the widget to "jsNotify" and script in
the widget or card, for example:

on jsNotify v
  put the seconds && v into fld "info"
end jsNotify

Don't use an alert here: You will also get the alert when you scroll a little
bit up from the bottom. This small indeterminate region is also influenced by
the horizontal scrollbar of the browser widget (which you can't control).

Related:
http://forums.livecode.com/viewtopic.php?p=152156#p152156
http://forums.livecode.com/viewtopic.php?p=156745#p156745

p.s. Answering is easier in the forum, especially if your questions become
more complicated (as soon as the browser widget has won you over).


_______________________________________________
use-livecode mailing list
[hidden email]
Please visit this url to subscribe, unsubscribe and manage your subscription preferences:
http://lists.runrev.com/mailman/listinfo/use-livecode