You need to sign in to do that
Don't have an account?
JK84
How to get Page Title in VF using Javascript
Hi,
I'm trying to get the title of the page in a VF page using Javascript (code is as follows) :
But, the alert is only displaying "Salesforce.com - Developer Edition", although I can see that the title in the "view Source" of the page is "<title>Candidates: Home ~ salesforce.com - Developer Edition</title>"
Any suggestions on where am I going wrong ?
<script type="text/javascript">
window.onload = function jfunction()
{
var pageTitle = document.getElementsByTagName("title")[0].innerHTML;
alert('page Title '+document.title);
}
</script>
Hi,
It's working fine for me. can you plz tell me where you have put your java script in VF page or any custom button java script.
I have the javascrip in a VF page and it is as follows :
<apex:page controller="NewAuditController" action="{!updateData}">
<script type="text/javascript">
window.onload = function jfunction()
{
var pageTitle = document.getElementsByTagName("title")[0].innerHTML;
alert('page Title '+pageTitle );
}
</script>
....
In your vf page add
<title> Your Page Name</title>
var pageTitle = document.getElementsByTagName("title")[0].innerHTML="Your Page Name";
I guess I missed adding an important point in the question. I was trying to fetch the title of the referrer URL, but not the current page URL.
The code I've written is displaying the current page URL, but how do we get the referrer page title in javascript?