diff --git a/dlls/mshtml/mshtml_private.h b/dlls/mshtml/mshtml_private.h
index 6d44f32d7b5..350ffbfa243 100644
--- a/dlls/mshtml/mshtml_private.h
+++ b/dlls/mshtml/mshtml_private.h
@@ -450,6 +450,7 @@ HTMLDOMNode *get_node(HTMLDocument*,nsIDOMNode*);
void release_nodes(HTMLDocument*);
void release_script_hosts(HTMLDocument*);
+void connect_scripts(HTMLDocument*);
void doc_insert_script(HTMLDocument*,nsIDOMHTMLScriptElement*);
IHTMLElementCollection *create_all_collection(HTMLDOMNode*);
diff --git a/dlls/mshtml/nsevents.c b/dlls/mshtml/nsevents.c
index 2fb5ab0bd08..eda1b544c7a 100644
--- a/dlls/mshtml/nsevents.c
+++ b/dlls/mshtml/nsevents.c
@@ -136,6 +136,7 @@ static nsresult NSAPI handle_load(nsIDOMEventListener *iface, nsIDOMEvent *event
if(!This->doc)
return NS_OK;
+ connect_scripts(This->doc);
setup_nswindow(This->doc->window);
if(This->editor_controller) {
diff --git a/dlls/mshtml/script.c b/dlls/mshtml/script.c
index 3388ca193b8..4dc1b06b52d 100644
--- a/dlls/mshtml/script.c
+++ b/dlls/mshtml/script.c
@@ -171,6 +171,16 @@ static void release_script_engine(ScriptHost *This)
This->script_state = SCRIPTSTATE_UNINITIALIZED;
}
+void connect_scripts(HTMLDocument *doc)
+{
+ ScriptHost *iter;
+
+ LIST_FOR_EACH_ENTRY(iter, &doc->script_hosts, ScriptHost, entry) {
+ if(iter->script_state == SCRIPTSTATE_STARTED)
+ IActiveScript_SetScriptState(iter->script, SCRIPTSTATE_CONNECTED);
+ }
+}
+
#define ACTSCPSITE_THIS(iface) DEFINE_THIS(ScriptHost, ActiveScriptSite, iface)
static HRESULT WINAPI ActiveScriptSite_QueryInterface(IActiveScriptSite *iface, REFIID riid, void **ppv)