Hi I'm looking for an API that retrieve page title in Javascript, for an address given.
Thanks
Hi I'm looking for an API that retrieve page title in Javascript, for an address given.
Thanks
You can retrieve the title of the current window by using document.title:
<button onclick="alert(document.title);">show title</button>
You can how ever use an iframe for different pages provided that they are on the same domain:
<script>
function iframeLoaded(iframe){
alert(iframe.contentWindow.document.title);
}
function getTitle(){
var url = "<some url here>";
var htm = '<iframe src="' + url + '" onload="iframeLoaded(this)"></iframe>';
document.getElementById('loader').innerHTML = htm;
}
</script>
<button onclick="getTitle()">get title</button>
<div id="loader" style="display:none">
</div>