diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h
index 08da2d78c44..90ba6adf2fc 100644
--- a/dlls/mshtml/mshtml_private.h
+++ b/dlls/mshtml/mshtml_private.h
@@ -308,6 +308,7 @@ struct HTMLWindow {
nsChannelBSC *bscallback;
IMoniker *mon;
+ IUri *uri;
BSTR url;
IHTMLEventObj *event;
diff --git a/dlls/mshtml/persist.c b/dlls/mshtml/persist.c
index 412dab71acf..2ad108dd9be 100644
--- a/dlls/mshtml/persist.c
+++ b/dlls/mshtml/persist.c
@@ -68,7 +68,7 @@ static BOOL use_gecko_script(HTMLWindow *window)
void set_current_mon(HTMLWindow *This, IMoniker *mon)
{
- WCHAR *url;
+ IUriContainer *uri_container;
HRESULT hres;
if(This->mon) {
@@ -76,6 +76,11 @@ void set_current_mon(HTMLWindow *This, IMoniker *mon)
This->mon = NULL;
}
+ if(This->uri) {
+ IUri_Release(This->uri);
+ This->uri = NULL;
+ }
+
if(This->url) {
SysFreeString(This->url);
This->url = NULL;
@@ -87,12 +92,36 @@ void set_current_mon(HTMLWindow *This, IMoniker *mon)
IMoniker_AddRef(mon);
This->mon = mon;
- hres = IMoniker_GetDisplayName(mon, NULL, NULL, &url);
+ hres = IMoniker_QueryInterface(mon, &IID_IUriContainer, (void**)&uri_container);
if(SUCCEEDED(hres)) {
- This->url = SysAllocString(url);
- CoTaskMemFree(url);
- }else {
- WARN("GetDisplayName failed: %08x\n", hres);
+ hres = IUriContainer_GetIUri(uri_container, &This->uri);
+ IUriContainer_Release(uri_container);
+ if(hres != S_OK) {
+ WARN("GetIUri failed: %08x\n", hres);
+ This->uri = NULL;
+ }
+ }
+
+ if(!This->uri) {
+ WCHAR *url;
+
+ hres = IMoniker_GetDisplayName(mon, NULL, NULL, &url);
+ if(SUCCEEDED(hres)) {
+ hres = CreateUri(url, 0, 0, &This->uri);
+ if(FAILED(hres)) {
+ WARN("CrateUri failed: %08x\n", hres);
+ This->url = SysAllocString(url);
+ }
+ CoTaskMemFree(url);
+ }else {
+ WARN("GetDisplayName failed: %08x\n", hres);
+ }
+ }
+
+ if(!This->url && This->uri) {
+ hres = IUri_GetDisplayUri(This->uri, &This->url);
+ if(FAILED(hres))
+ WARN("GetDisplayUri failed: %08x\n", hres);
}
set_script_mode(This, use_gecko_script(This) ? SCRIPTMODE_GECKO : SCRIPTMODE_ACTIVESCRIPT);