1. This website uses cookies to improve service and provide a tailored user experience. By using this site, you agree to this use. See our Cookie Policy.
    Dismiss Notice

How to grab page title?

Discussion in 'Web Design' started by hckone, Mar 11, 2018.

  1. hckone

    hckone Junior Member

    Joined:
    Apr 24, 2010
    Messages:
    101
    Likes Received:
    7
    Hi to all! Can someone please tell me and knows how to grab page title and post that title to the same page?? I have basic HTML but can't find the solution. Thanks!
     
  2. rimvy

    rimvy Regular Member

    Joined:
    Oct 8, 2017
    Messages:
    455
    Likes Received:
    155
    Gender:
    Male
    Location:
    localhost
    Explain better what you trying to achieve, because now it's really hard to understand.
     
  3. hckone

    hckone Junior Member

    Joined:
    Apr 24, 2010
    Messages:
    101
    Likes Received:
    7
    Simple as that, I m trying to get page title and post as a content of my web page as HTML,
     
  4. hckone

    hckone Junior Member

    Joined:
    Apr 24, 2010
    Messages:
    101
    Likes Received:
    7
    Display title of the web page as a content in the same page inside, when refresh each page has a different title name I want to grab that page title and display as a page content
     
  5. Demosk

    Demosk Newbie

    Joined:
    Apr 8, 2017
    Messages:
    17
    Likes Received:
    7
    Gender:
    Male
    If I understand well what you need to do then it depends if you are using a CMS like wordpress then you can do it with built in functions of the CMS however you can do this with javascript too. I wrote a small jQuery script that will help you to do this:

    Code:
    $(document).ready(function() {
    
        var titlename = document.title;
        var myelement = $("<h2></h2>").text(titlename);
        $("#div1").append(myelement);
        return this;
    
    });
    
    In this case what I did was to create an h2 element and add it inside the div element with id div1. You can change this to whatever your element id is and whatever type of element you want to create, don't forget to add the jQuery CDN so that your script can work. Let me know if this is confusing or need more help understanding what you need to do.
     
  6. hckone

    hckone Junior Member

    Joined:
    Apr 24, 2010
    Messages:
    101
    Likes Received:
    7
    Thank you so much Demosk
     
  7. Demosk

    Demosk Newbie

    Joined:
    Apr 8, 2017
    Messages:
    17
    Likes Received:
    7
    Gender:
    Male
    You're welcome.
     
  8. RankBoss

    RankBoss Jr. VIP Jr. VIP

    Joined:
    Nov 21, 2016
    Messages:
    797
    Likes Received:
    223
    Gender:
    Male
    Occupation:
    Online business service consultant
    Location:
    Within your range
    Just go to an SEO comparison site
    Type the site name

    It crawls and shows all the details