diff --git a/inc/html.php b/inc/html.php
index 2fc6bfe370b9727fda8652180ea1e34c983286b8..edfc5a2cbc17649106190085c36b4ed95af5c26f 100644
--- a/inc/html.php
+++ b/inc/html.php
@@ -332,11 +332,12 @@ function html_search(){
   flush();
 
   //show progressbar
-  print '<div class="centeralign">';
+  print '<div class="centeralign" id="dw__loading">';
+  print '<br /></div>';
   print '<script type="text/javascript" charset="utf-8">';
-  print 'showLoadBar();';
+  print 'showLoadBar("dw__loading");';
   print '</script>';
-  print '<br /></div>';
+  flush();
 
   //do quick pagesearch
   $data = array();
@@ -379,8 +380,9 @@ function html_search(){
 
   //hide progressbar
   print '<script type="text/javascript" charset="utf-8">';
-  print 'hideLoadBar();';
+  print 'hideLoadBar("dw__loading");';
   print '</script>';
+  flush();
 }
 
 /**
diff --git a/lib/scripts/script.js b/lib/scripts/script.js
index 834f0f4a451669691bdd0fd681ec187eddfe6580..24dc025bcaed8e54cb8a27892b043bf9ccb0b63b 100644
--- a/lib/scripts/script.js
+++ b/lib/scripts/script.js
@@ -129,10 +129,13 @@ function prependChild(parent,element) {
  *
  * @author Andreas Gohr <andi@splitbrain.org>
  */
-function showLoadBar(){
-  if(document.getElementById){
-    document.write('<img src="'+DOKU_BASE+'lib/images/loading.gif" '+
-                   'width="150" height="12" id="dw__loading" />');
+function showLoadBar(id){
+  obj = $(id);
+
+  if(obj){
+    obj.innerHTML = '<img src="'+DOKU_BASE+'lib/images/loading.gif" '+
+                    'width="150" height="12" alt="..." />';
+    obj.style.display="block";
   }
 }
 
@@ -141,10 +144,9 @@ function showLoadBar(){
  *
  * @author Andreas Gohr <andi@splitbrain.org>
  */
-function hideLoadBar(){
-  if(document.getElementById){
-    $('dw__loading').style.display="none";
-  }
+function hideLoadBar(id){
+  obj = $(id);
+  if(obj) obj.style.display="none";
 }
 
 /*