function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ramesh Maamidi 6Ramesh Maamidi 6 

Javascript not getting executed in Visualforce page

Hi all,

Here is my code:
<apex:page standardController="Student__c" extensions="GenerateCSV" action="{!generate}" cache="true" contentType="text/csv#{!exportFileName}" language="en-US">
    <script type='text/javascript' src='/canvas/sdk/js/publisher.js'></script>
    <script type="text/javascript">
        Sfdc.onReady(function(){
            alert('onReady');
        });
    </script>
    <apex:outputText value="{!exportStr}"/>
</apex:page>

Here the alert is not getting executed. If I remove contentType property it works fine. But, I need even that. All I need is to execute javascript after downloading a CSV file. Please help!!
Balu_SFDCBalu_SFDC
use <apex:actionfunction name ="genreteCSV" action="{!generate}" oncomplete ="oncomplteHanle();"/>
on load call  genreteCSV() like this;
window.onload() {
  genreteCSV();
}

function oncomplteHanle() {
     Sfdc.onReady(function(){
           alert('onReady');
});
}
Ramesh Maamidi 6Ramesh Maamidi 6
Thank you Balu, butr this is not working. Please notice that I've contentType="text/csv#{!exportFileName}".