You need to sign in to do that
Don't have an account?
How to add to the <HEAD> dynamically
We ran into a problem of needing to add a <META> tag to the <HEAD> of the brower in Salesforce. You can add Javascrpt with the <apex:includeScript>, but there is current no documented way of adding other tags such as <META>
Here is a trick that I developed and appears to be working nicely:
I added a JavaScript file to the <HEAD> using <apex:includeScript value="{!$Resource.stevefix}"/>
The file: stevefix contains:
-------------
function addToHEAD()
{
newScript = document.createElement('meta'),
newScript .setAttribute('name', 'flag #1');
newScript .setAttribute('content', 'true');
var meta = document.getElementsByTagName('SCRIPT')[0];
meta.parentNode.appendChild(newScript );
}
addToHEAD();
----------
This works by:
#1 The JS file is added in the head.
#2 Inside, it defines a function: addToHEAD()
#3 It calls the function addToHEAD.
Inside the function, I use the DOM to find the first instance of <SCRIPT>. This could actually be the JS itself, or another one from SF.
It creates a new tree node, populates it with the proper values.
Then it adds it to the parent of the found <SCRIPT>. (adds as a sibling of the found script).
Using this method, we may be able to add whatever we need to the <HEAD>.
Good luck and I hope that it helps.
Steve Simpson
Ethos - www.ethos.com