+ Start a Discussion
bob_buzzardbob_buzzard 

ActionPoller, JavaScript and IE woe

I have a VF page that contains an actionpoller to refresh a section every 'n' seconds.  In order to let the user know that this is happening, I'm using an actionstatus with start/stop attributes to invoke javascript functions.

 

I've found that while this works fine in Chrome and Firefox, IE 7 and 8 throw errors.  I've managed to dwindle this down to the following page:

 

 

 

<apex:page tabstyle="Account" showheader="false" standardstylesheets="true">
   <script>
      function start()
      {
         alert("Starting");
      }
   
      function stop()
      {
         alert("Stopping");
      }
   </script>   

<!--    <h1>Poller Test</h1> -->

   <apex:form >
      <apex:actionStatus id="sref"
                onstart="start()" onstop="stop()"/> 
   
      <apex:actionPoller interval="10" rerender="status" status="sref"/>

      <apex:outputPanel id="status">
          Here is the panel
      </apex:outputPanel>
   </apex:form>
</apex:page>

 

When I access this page in IE, I get JavaScript errors that 

Webpage error details
User Agent: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; InfoPath.2)
Timestamp: Tue, 3 Aug 2010 10:37:26 UTC
Message: 'window.document.getElementById(...)' is null or not an object
Line: 17
Char: 1
Code: 0
Message: 'window.document.getElementById(...)' is null or not an object
Line: 19
Char: 1
Code: 0

 

'window.document.getElementById(...)' is null or not an object'.  If I remove the comment around the line:

 

 

<!--    <h1>Poller Test</h1> -->

 

 

Then it works fine for IE.  

 

It appears that inserting some regular HTML in between the javascript and apex:form components fixes it, but I've no idea why.  

 

Any suggestions as to what is causing this (I've already drawn the obvious conclusion that its an IE bug!)

 

 

ScoobieScoobie

I've had this problem to but I was happy to go with the work around instead of worrying about it. IE is just not a very good product.

Pradeep_NavatarPradeep_Navatar

There was some problem in your code. Find below the modified code :

 

                <apex:page tabstyle="Account" showheader="false" standardstylesheets="false">

                    <apex:form >

                          <apex:outputPanel>

                          Here is the panel

                          </apex:outputPanel>

                          <apex:actionPoller interval="5" rerender="status" status="sref"/>

                          <apex:actionStatus onstop="stop() " />

                           <script>

                            function start()

                            {

                            alert("Starting");

                            }

                            function stop()

                            {

                                alert("Stopping");

                             }

                             </script> 

                    </apex:form>

                </apex:page>

 


Did this answer your question? if so, please mark it solved.

bob_buzzardbob_buzzard

The code doesn't work as the rerender/status attribute ids don't exist in the page.

bob_buzzardbob_buzzard

Having fixed the code above, it does cause the onstop to fire.  Thus it appears to be an ordering issue.of the javascript sequencing straight into the form tag.  Still not managed to reproduce it on any other browser though, so it does appear to be an IE gotcha.