Javascript detecting iframe vertical scroll position

Trying to detect that someone has scrolled to the bottom of the iframe and "legally" read the text... Parent document has a form (splash) and an input field (legal) with original value of 0.

<script language="JavaScript">
var position = 0;

function startPolling(){setInterval("poll()",500)}

function poll(){
if (navigator.appName == "Microsoft Internet Explorer"){var position = document.body.scrollTop;}
else {var position = window.pageYOffset;}

if (position > 150)
{
      parent.document.splash.legal.value='1';
}

return true;

}
</script>
</head>

<body onLoad="startPolling()">

This is where the long text is...

</body>
</head>

It's not setting the value :( Any ideas what's wrong?
djrubinAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

smaccariCommented:
Your function works for me (i put an alert instead of modifying an input's value) - test made with IE6.
djrubinAuthor Commented:
Nice to know I did that right, but why doesn't my value show any change in the parent script nor on its submission.... hmmm...

Here's the code on the parent...

<body bgcolor="#ffffff">
<cfform name="splash" id="splash" action="index.ep" method="post">
<table align="left" border="0" cellpadding="0" cellspacing="0" width="784">
              <tr>
               <td><img name="splash_r3_c1" src="images/splash_r3_c1.gif" width="104" height="153" border="0" alt=""></td>
               <td width="575" height="153" background="images/splash_r3_c2.gif">
                        <iframe src="disclaimer.ep" name="BottomFrame" width="100%" scrolling="auto" id="BottomFrame" allowtransparency="true">
                              Your browser does not support iframes.
                        </iframe>         
                  </td>
               <td><img name="splash_r3_c8" src="images/splash_r3_c8.gif" width="105" height="153" border="0" alt=""></td>
              </tr>
            </table>

      <cfinput type="text" name="legal" value="0">
</cfform>
</body>

Did I do something wrong on "top"?
smaccariCommented:
Do you have an error, or is it just doing nothing?
If you place an alert in your function, do you see it pop?:

function startPolling(){setInterval("poll()",500)}

function poll(){
if (navigator.appName == "Microsoft Internet Explorer"){var position = document.body.scrollTop;}
else {var position = window.pageYOffset;}

if (position > 150)
{
   alert("foo");  
   parent.document.splash.legal.value='1';
}

return true;

}
Big Business Goals? Which KPIs Will Help You

The most successful MSPs rely on metrics – known as key performance indicators (KPIs) – for making informed decisions that help their businesses thrive, rather than just survive. This eBook provides an overview of the most important KPIs used by top MSPs.

djrubinAuthor Commented:
Firefox it works fine... IE nothing. I put in the alert and see it in FF (thanks for the endless loop of pop ups :) I added a detecting IF so that it appears once). Nothing in IE, no popup and no value changing... is there something wrong with the IE detection part of the code?
djrubinAuthor Commented:
Well here's the answer folks...

Needed to change the first line of the poll function to:

if (navigator.appName == "Microsoft Internet Explorer"){var position = document.documentElement.scrollTop;}

seems document.body.scrolltop is not good enough for IE so you have to reference it by documentElement

Now all works fine.
GranModCommented:
Closed, 500 points refunded.
GranMod
The Experts Exchange
Community Support Moderator of all Ages

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
JavaScript

From novice to tech pro — start learning today.