Forum Moderators: open

Message Too Old, No Replies

Can I output <title>Page</title> using Javascript?

         

dvduval

3:40 am on Nov 30, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm working with a shopping site that uses javascript to output the products like this:

mysite.com/brand.html?product=3

Currently the javascript function calls the values for product 3 from a js file and outputs them in the body of the page.

My goal is to give each page a <title> based on this function. I want to display product 3's name as the title of the page. Can I call the function and then output the value in the title tag using javascript?

GeorgeGG

3:46 pm on Nov 30, 2003 (gmt 0)

10+ Year Member



I use something like this:
<noscript><title>Default Title For Page</title></noscript>

var Item_Title = "Default Title For Page";

Include this in your product # js file:
Item_Title = "product #'s name";

After the call to the include js file, include in page:
<script TYPE="text/javascript">
document.write("<title>"+Item_Title+"</title>");
</script>

GGG

moonbather

4:15 am on Dec 1, 2003 (gmt 0)

10+ Year Member



document.title="item1"