开发者

NS_ERROR_FAILURE with absent property

开发者 https://www.devze.com 2023-02-10 10:49 出处:网络
I trying to capture pageLoad event in progressListener, in onLocationChange i check URI of fresh page, and in case URI = about:blank i got

I trying to capture pageLoad event in progressListener, in onLocationChange i check URI of fresh page, and in case URI = about:blank i got

Error: Component returned failure code: 0x80004005 (NS_ERROR_FAILURE) [nsIURI.host]

As i understand this URI don't have host at all.

How can i check that host is available without raw parsing and exception catching? I开发者_运维知识库s there any conventional way to check that atribute is present?


Your best bet is to filter certain protocols (filter on scheme). It's best to use a whitelist in this case of the protocols you care about.


In general there's no way to know for sure without doing a try/catch, but currently an nsIStandardURL is the only sort of URI that will have a host.


When I faced this problem my solution was: To indicate an observer flag aWebProgress.NOTIFY_LOCATION

aWebProgress.addProgressListener(this.listener, aWebProgress.NOTIFY_LOCATION);

Before I had aWebProgress.NOTIFY_LOCATION and there was an exception you desc

0

精彩评论

暂无评论...
验证码 换一张
取 消