获取URL,通过Javascript而不是jQuery获取标题

获取URL,通过Javascript而不是jQuery获取标题,javascript,jquery,url,get,title,Javascript,Jquery,Url,Get,Title,有人知道如何在不使用jQuery的情况下使用Javascript获取当前页面的url和标题吗 var title=document.getElementsByTagName('title')[0].innerHTML; var url=document.location.href 社交(encodeURIComponent('+href+')、encodeURIComponent('+title+')) 就是不管用。。需要帮助…您需要的是URL片段: var currentURL = wi

有人知道如何在不使用jQuery的情况下使用Javascript获取当前页面的url和标题吗



var title=document.getElementsByTagName('title')[0].innerHTML;
var url=document.location.href
社交(encodeURIComponent('+href+')、encodeURIComponent('+title+'))
就是不管用。。需要帮助…

您需要的是URL片段:

var currentURL = window.location.href;
标题是:


window.location.href
用于URL,
document.title
用于标题。

thx但这里有什么问题:var href=window.location.href;var title=window.location.title;社交(encodeURIComponent('+href+')、encodeURIComponent('+title+'))@venom使用
document.title
作为标题:)
var currentURL = window.location.href;
var title = document.title;
var title = document.getElementsByTagName('title')[0].innerHTML;
var url = document.location.href;