SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Hybrid View

  1. #1
    SitePoint Enthusiast
    Join Date
    Aug 2005
    Posts
    64
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    help with simple code please

    hi all,

    I need simple javascrit to do the following..

    for example..
    I have a page and its title ie "Janu's Home Page", what I want is to somehow get the value of page title and remove everything after "'s" I mean I should somehow get the value of title like this..

    Janu

    it should remove 's Home Page

    and display this title in body or addisng htis value to a variable $mytitle

    I dont know much JS, please help here.

  2. #2
    SitePoint Guru
    Join Date
    Sep 2006
    Posts
    731
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by janu View Post
    hi all,

    I need simple javascrit to do the following..

    for example..
    I have a page and its title ie "Janu's Home Page",
    it should remove 's Home Page

    and display this title in body or addisng htis value to a variable $mytitle

    I dont know much JS, please help here.
    Choose whichever is easiest to explain to your teacher:
    Code:
    var myTitle=document.title.split("'")[0];
    
    var myTitle=document.title.replace(/^([^\']+)\'.*$/,"$1");
    
    var myTitle=document.title.substring(0, document.title.indexOf("'") );
    Tab-indentation is a crime against humanity.

  3. #3
    SitePoint Enthusiast
    Join Date
    Aug 2005
    Posts
    64
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    thanks Ali


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
  •