...

View Full Version : Dynamically entering month into the TITLE TAG - possible?



Azam.net
03-26-2005, 12:04 PM
How can I add the month to the title of a page please?

Want to do something like

<TITLE>Special Offers this [MONTH]!</TITLE>

Tried inserting Javascript I usually use in my HTML to show the show to the title tag, but didn't work of course!


<SCRIPT LANGUAGE="JavaScript">

<!-- Begin
var months=new Array(13);
months[1]="January";
months[2]="February";
months[3]="March";
months[4]="April";
months[5]="May";
months[6]="June";
months[7]="July";
months[8]="August";
months[9]="September";
months[10]="October";
months[11]="November";
months[12]="December";
var time=new Date();
var lmonth=months[time.getMonth() + 1];
var year=time.getYear();
document.write(" " + lmonth + " ");

// End -->
</SCRIPT>

Many thanks :)

coothead
03-26-2005, 01:21 PM
Hi there Azam.biz,

try it like this...

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>

<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8" />

<script type="text/javascript">
//<![CDATA[

var months=new Array();
months[0]="January";
months[1]="February";
months[2]="March";
months[3]="April";
months[4]="May";
months[5]="June";
months[6]="July";
months[7]="August";
months[8]="September";
months[9]="October";
months[10]="November";
months[11]="December";

var now=new Date();
var num=now.getMonth();

function titleMonth() {

document.title="Special Offers for "+months[num];

}
onload=titleMonth;
//]]>
</script>

</head>
<body>

<div> </div>

</body>
</html>

coothead

Azam.net
04-11-2005, 02:20 PM
Thanks a million for that. Really appreciate your help coothead.

Is there any way of inserting month into Title in a search-engine friendly way? I imagine that doing it via Javascript wouldn't be looked upon favourably by the search bots.

Cheers.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum