The problem:
I want to open an excel document automatically from a custom aspx page in the layouts folder (sharepoint 2010) which refers to a document in a document library. The "DocumentUrl" is replaced automaticly with the correct url and the excel opens. But what's strange is that the page keeps reloading and thus also opening the excel document. Anyone who knows what the problem might be?
The code:
<a id="openExcelCreate" href="<%= DocumentUrl %>" onclick="return DispEx(this,event,'TRUE','FALSE','FALSE','SharePoint.OpenDocuments.3','1','SharePoint.OpenDocuments','','','','1','0','0','0x7fffffffffffffff','','')">Download File</a>
<script type="text/javascript">
document.getElementById("openExcelCreate").click();
</script>
Updates: I've tried adding "evt.preventDefault();" to the onclick event and the page doesn't reload anymore, but then we have some troubles with saving the excel document... all kind of conflicts (file locked, ...)
DispEx
?g_varSkipRefreshOnFocus = true;
beforedocument.getElementById("openExcelCreate").click();