Dynamic Page Title

Is there a way to use what is located between the title tags of a cfm page as a variable and output it in other areas of the page? I'm using a cfinclude header page on all of the pages in my site. I want the page title to be read and outputted dynamically into my common header. How do you read what is between the title tags and output it?
Dennis_HalseyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

deepchandaCommented:
U can use the javascript property "title" of document object to return the value between the <title> tags. It would look like this, document.title. All this would be client-side javascript code, so after the web page has been loaded in the browser, this value can be available in all the javascript code u use to access this property

DC
0
Nathan Stanford SrSenior ProgrammerCommented:
<cfset CHeader ="This is my Title">

<cfinclude template="header.cfm">






Inside the Header.cfm file
<cfoutput>
<title>#cheader#</title>
<body>
Main Page - #cheader#


Does this help?

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Dennis_HalseyAuthor Commented:
Is there a way to use what is located between the title tags of a cfm page as a variable and output it in other areas of the page? I'm using a cfinclude header page on all of the pages in my site. I want the page title to be read and outputted dynamically into my common header. How do you read what is between the title tags and output it?

Since I'm a Web designer and programmer, I'm seeking ways to save time using dynamic headers. I really need to read what is already between a page's title tags without using a cfset to get it. Isn't there some kind of a variable like url.pagetitle or something that can read the title tag? I've included my two templates below so you can see what I'm doing. Thanks for your help
0
Nathan Stanford SrSenior ProgrammerCommented:
Sorry as far as I know there is no way variable to do that however what I might would do different is.


Create the Header as a Custom Tag

in the File use the below link


<cfmodule template ="/includes/header.cfm" title="Main Page">


Then inside the file header.cfm in the includes directory does not need to be this way just the way I seperate my include files from my regular files.

<cfoutput>
<title>#attributes.title#</title>
</cfoutput>

My email is nathan@nsnd.com
My website is www.nsnd.com


0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Servers

From novice to tech pro — start learning today.