Search

Matthew Knott

Previous: NinePlanFailed rock Nantyglo RFC
Next: Generic NinePlanFailed gig review

Stop DispEx Redirecting in SharePoint

Posted on Sunday, 30 August 2009 11:09

Ever tried to use the DispEx javascript function in SharePoint to edit a codument, but it causes a page refresh after? Here's how to stop the nonsense!


When you call the DispEx function in SharePoint, to edit a document, as soon as you close the office application, the SharePoint page "refreshes" (it actually re-routes back on itself.

Ths is fine for most people, but in my bespoke application, it was something of a problem as I did not want a reload or a refresh.

To achieve this, you just need to add the following code:

  1. <script type="text/javascript">
  2. g_varSkipRefreshOnFocus = true;
  3. </script>

Hope you find this as useful as I did.

Comments

  • Thank you so much, posted by ZiGGstern

    This information saved me a lot of work. Thx mate

  • No problem, posted by Matt

    You're most welcome, glad it helped, did my head in for hours!

  • SP2, posted by Pedro

    Before Sp2 he didnt do a refresh right?

    Because we didnt had sp2 and this DispEx worked ok, after sp2 install this stoped working and we had to do this litle trick. strange right?

  • RE: SP2, posted by Matt

    You could be right there Pedro, unfortunately when I came across this fix we were running SP2, I haven't tried it on older software.

  • Good Solution, posted by Jason

    Where does it go in the ASPX file? I put this javascript in the area of the html document, no dice.

  • Jason, posted by Matt

    You need to put the code in after core.js and before you start your code. Will work in a content editor webpart.

  • Alternate solution, posted by Shah

    Just before the DispEx method call, call the method DisableRefreshOnFocus();

    I used this in my search result.aspx xml to stop refreshing my search result.

  • ICT Systems Developer, posted by Nicola

    Hi I have added this code into a CEWP and placed it at the bottom of the page, the trouble is it only works when the view of the document library has the ?PageView=Shared appended to the URL - it works fine then i.e. no page refresh but as soon as you remove ?PageView=Shared, which is how normal users will see it - it no longer works. I have tried adding to the Master Page - but need help with this i.e. the steps of how to do this.

    Thanks,

    Nicola

  • Great, posted by Nicola

    Thanks dude! I had to put it in an XSLT view i put it right before the DispEx func and it works like a charm!

    thanks a lot, how did u came up with that variable?

  • No worries, posted by Matt

    Hi Nicola,

    Glad it helped! Sorry I didn't respond to your last comment, life's been a bit mental for the last few months.

    Found it by scouring through a LOT of JavaScript and a lot of trial and error. Glad it's helped so many people it's practically the only thing I've ever contributed to the SharePoint community.

Add a comment