SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    Non-Member
    Join Date
    Apr 2005
    Location
    New Zealand
    Posts
    112
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Code to Change <title> for Homepage Only

    Hi All

    First I asked for a PHP solution to this, but it appears the PHP isn't parsed in the <title> tags by my site code (could be something to do with the Smarty template system?).

    Anyway, I think it can parse Javascript, so was just wondering if anyone knows how to do this:

    I am just editing the title tags for one of my sites, and I want it like (example):

    For the home page: Welcome to XXXX - The Best Site for XXXX

    For other pages: Welcome to XXXX
    The PHP thread is here.

  2. #2
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    but it appears the PHP isn't parsed in the <title> tags by my site code. Anyway, I think it can parse Javascript
    That's not the way it works. Javascript is parsed/executed by a user's browser, which is long after php has finished executing on the server.
    Code:
    window.onload = function()
    {
           document.getElementsByTagName("title")[0].firstChild.nodeValue = "Hello world";
    }


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •