有谁知道如何在没有 jQuery 的情况下使用 Javascript 获取当前页面的 url 和标题!?
<script type="text/javascript">
var title = document.getElementsByTagName('title')[0].innerHTML;
var url = document.location.href
socializ(encodeURIComponent('+href+'),encodeURIComponent('+title+'))
</script>
只是行不通..需要帮助...
最佳答案
location
object是您要查找的 URL 部分:
var currentURL = window.location.href;
对于标题,document.title
:
var title = document.title;
关于javascript - 获取 URL,通过 Javascript 而不是 jQuery 获取标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4368626/