Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dynamically changing the Title of a webpage

Status
Not open for further replies.

arundahar

Programmer
Apr 27, 2001
53
GB
Hi, can anyone tell me how to dynamically change the <TITLE> of a webpage. Currently our site displays the same title on ALL pages, but depending on the product that is being viewed i want to change the <Title> tag,

Any ideas?

Thanks

A
 
You could try using a Server side script, like ASP, PHP, etc...

or change in every page the title.... :)
 
ok, so how do i change the <TITLE> of a page with ASP?
 
From JavaScript:

document.title = &quot;New Title.&quot;;


Or if you can write them in with ASP by doing just that - write in the text. This is good sometimes if you want to add data source from previous page, database, or cookies etc.

<title><%=&quot;New Title&quot;%></title>

[bb]
 
yeah but i need ASP to proces first, i can't change the TITLE at the top as i don't know what to call it yet!
 
if you have the titles in a DB then just make a Select on that table, and on the <title> just put something like:
<title><%=title%></title>

an example

<%
set rs_title = Server.CreateObject(&quot;ADODB.Recordset&quot;)
conn = &quot;Select * from titles&quot;
set rs_title = objConexao.Execute(conn)

title = rs_title(&quot;title&quot;)

'dont forget to close the connection
%>

<html>
<title><%=title%></title>
<body>
bla bla
.
.
.
</body>
</html>
 
ohhh.... don't forget to use the where clause so you can select the right title..

Hope this help

NiteCrawlr
 
Another idea,

if the titles are not in a DB, create an Include file:


************************
*** Include_File.inc ***
<%
id = Request.QueryString(&quot;id&quot;)

Select case id
case &quot;1&quot;
title = &quot;Product1&quot;
case &quot;2&quot;
title = &quot;Product2&quot;
case &quot;3&quot;
title = &quot;Product3&quot;
case else
end select
%>


*************************
*** Product_List.asp ****

<a href=&quot;productinfo.asp?id=1&quot;>Product1</a>
<a href=&quot;productinfo.asp?id=2&quot;>Product2</a>
<a href=&quot;productinfo.asp?id=3&quot;>Product3</a>



***********************
*** ProductInfo.asp ***

<!--#Include File=&quot;Include_File.inc&quot; -->

<html>
<title><%=title%></title>
<body>
.
.
.
</body>
</html>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top