diff --git a/content/html/document/src/nsHTMLContentSink.cpp b/content/html/document/src/nsHTMLContentSink.cpp
index da457dc61e6f..1eb7e77807e3 100644
--- a/content/html/document/src/nsHTMLContentSink.cpp
+++ b/content/html/document/src/nsHTMLContentSink.cpp
@@ -4344,7 +4344,9 @@ HTMLContentSink::ScrollToRef(PRBool aReallyScroll)
mDocument->GetShellAt(i, getter_AddRefs(shell));
if (shell) {
// Scroll to the anchor
- shell->FlushPendingNotifications(PR_FALSE);
+ if (aReallyScroll) {
+ shell->FlushPendingNotifications(PR_FALSE);
+ }
// Check an empty string which might be caused by the UTF-8 conversion
if (!ref.IsEmpty()) {
diff --git a/content/xml/document/src/nsXMLContentSink.cpp b/content/xml/document/src/nsXMLContentSink.cpp
index ebdc62cf1e23..0ec11a8835ed 100644
--- a/content/xml/document/src/nsXMLContentSink.cpp
+++ b/content/xml/document/src/nsXMLContentSink.cpp
@@ -352,7 +352,9 @@ nsXMLContentSink::ScrollToRef(PRBool aReallyScroll)
mDocument->GetShellAt(i, getter_AddRefs(shell));
if (shell) {
// Scroll to the anchor
- shell->FlushPendingNotifications(PR_FALSE);
+ if (aReallyScroll) {
+ shell->FlushPendingNotifications(PR_FALSE);
+ }
// Check an empty string which might be caused by the UTF-8 conversion
if (!ref.IsEmpty())