Wednesday, April 3, 2013

Execute Java Script On Every Screen Of SFDC

The aforementioned blog which I am posting was the severe demand of one of my client who was wondering if we could deliver some code that will be executed on every standard screen of Salesforce.

So ,  the theoretical requirement was cited on the fact that Mr. Client was in urge of some code which would run on every standard page load in salesforce. For this I made an recipe which I am sharing below. Hope that you like it .

For this, You can make one "Narrow Home Page Component". 

In that component you can simply use below JS code and alter according to your need.

<script type="text/javascript" language="javascript">
try    {
   var doc =;
   var head = doc.head;
   var scriptElement = doc.createElement('script');
   scriptElement.async = true;
   scriptElement.innerHTML = "alert('test1')";
catch(e){  }

and add that to your home page layout.

Make sure you have enabled that sidebar component to show on all pages of your sfdc. 
Setup -> customize -> user Interface

You can also use this code by a deploying this package -

NOTE: After deployed this package please assign "JS on Every Screen Layout" to System Administraor Profile or profile that you want to use this functionility. 

Result - 


  1. Raj - will this work on a Sales Cloud console?

    1. Yes, its working on sales Cloud console.