I am working on one web application. I am interested in to fetch selected tab URL. I am using Firefox browser.
I achieved this by executing below javascript statements :
/* Get the URL of page which is currently loaded in active tab */
var currentPageURl = window.top.getBrowser().select开发者_如何学PythonedBrowser.contentWindow.location.href;
alert(currentPageURl);
Above statement work if page is loaded. But if I open's a new tab on Firefox browser (not entered any URL ) and executes above javascript. I am getting about:blank as a result.
I wanted to add such javascript statements which should handle such that if current page is loaded in tab then only gives URL, if page is not loaded then it should return false instead of about:blank
Your suggestions are welcome!!!
Thanks
-Pravin
Use &&
or an if statement to check the value:
// return false if about:blank, url if anything else
return currentPageURl != "about:blank" && currentPageURl;
Equivalent of
if (currentPageURl == "about:blank")
return false;
else
return currentPageURl;
精彩评论