Can I get the url of the address bar from the javascript console when the page has not loaded?
I'll just say that I typed the wrong hostname in the address bar.
For example, let's say I didn't have a local web server and I download:
http://localhost/callback_url
On Chrome this will give me the message "This page is not available".
Is there anyway I can find out that the url is in the address bar from the Javascript console even if the page hasn't loaded?
I know I can usually use window.location.href
to do this, but in this case it returns "data:text/html,chromewebdata"
.
So, in this example, I would like to know if there is any javascript that returns http://localohost/callback_url
EDIT: The main reason I would like to do this is because I know that server side redirection when using ChromeDriver with Selenium failed. So I would rather avoid using extensions if possible, and I open Chrome and ChromeDriver specific solutions if applicable! Additional information added by the server may be added to the callback_url and I would like to see what that information is. I would like to avoid starting another server to get this data if possible.
source to share
You can get it from the page title. By typing document.title
and doing some regex you can get the url.
Another way I have found is using the following
var data = loadTimeData.createJsEvalContext();
console.log(data.a.$top.summary.failedUrl);
If you open the developer tools and look for a portion of the URL in the source code, you can see what Chrome creates loadTimeData
in the "inaccessible page" page.
source to share