How to get current URL of website on the TWebBrowserControl

Hi Bruno,

Just a quick question here, Do you know how to get current URL for the page of website sitting on WebBrowser control?

Thanks,

Try:

var
  el: TJSElement;
  url: string;
begin
  el := webbrowsercontrol1.ElementHandle;
  asm
    url = el.contentWindow.location;
  end;
end;

Thanks Bruno for reply.

I tried in a test project and it throwed error:

Uncaught DOMException: Blocked a frame with origin "http://localhost:8000" from accessing a cross-origin frame.

Is there is way to overcome this?

Thanks for the help,

I suspect that what you show in the TWebBrowserControl is in a different domain?
If so, it is a security policy that from an external source, this URL cannot be returned.

Yes, for now we are using different domain for testing purpose. But in the coming future, we will merge it into our domain. Anyway, thanks so much for the verification. That helps a lot!