Posted by : Jebastin Sunday 15 December 2013

Get current HTML page Title and URL with jQuery and Javascript.

Current Page Title:

jQuery:

  1. var title = $(document).find("title").text();
  2. (or)
  3. var title = $('title').text(); 
  4. (or)
  5. var title = $(document).attr('title');

Javascript:

  1. var title = document.getElementsByTagName("title")[0].innerHTML;

Current Page URL:

jQuery:

  1. var url = $(location).attr('href');
  2. (or)
  3. var url = $(location).attr('pathname');

Javascript:

  1. var url = document.URL
  2. (or)
  3. var url = window.location.href
  4. (or)
  5. var url = window.location.pathname;

Leave a Reply

Subscribe to Posts | Subscribe to Comments

Link To This Post/Page

Spread The Word

Add this button to your blog:
JJ Technology Solutions

Blog Archive

Trackers

eXTReMe Tracker
facebook

- Copyright © JJ Technology Solutions - Powered by Source Code Solutions -