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
Mike @ BlackTabMike @ BlackTab 

Run Javascript inside a PageReference

I'm trying to run a javascript function: box.hide(); after the "burns" records are saved. How can I use a PageReference to execute javascript, or is there another way?

 

public pageReference save(){
         insert burns;
         PageReference back = new PageReference(JAVASCRIPT GOES HERE);
         back.setRedirect(true);
         return null;
}

 

WorkhardWorkhard

Hi,

As you know Javascript is a client side scripting language. So you can't use Javascript inside the controller. So you have to use javascript on your VF page insted of controller.

Mike @ BlackTabMike @ BlackTab

Thanks, I actually figured it out. 

 

I added an "oncomplete" attribute and insereted the javascript code.