How to grab page title?

hckone

Junior Member
Joined
Apr 24, 2010
Messages
197
Reaction score
26
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!
 
Explain better what you trying to achieve, because now it's really hard to understand.
 
Simple as that, I m trying to get page title and post as a content of my web page as HTML,
 
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
 
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.
 
Thank you so much Demosk
 
Just go to an SEO comparison site
Type the site name

It crawls and shows all the details
 
Back
Top