diff --git a/inline/web_widgets_inline.tpl.php b/inline/web_widgets_inline.tpl.php
index 3d81e90..eef9732 100644
--- a/inline/web_widgets_inline.tpl.php
+++ b/inline/web_widgets_inline.tpl.php
@@ -1,12 +1,11 @@
 <?php
-// $Id: web_widgets_inline.tpl.php,v 1.1 2009/06/24 07:38:58 aronnovak Exp $
 /**
  * @file
- * Template for the code what to embed in external sites
+ * Template for the code for what to embed in external sites
  */
 ?>
 <script type="text/javascript">
-widgetContext = <?php print $js_variables ?>;
+widgetContext_<?php print $id_suffix ?> = <?php print $js_variables ?>;
 </script>
 <script src="<?php print $script_url ?>"></script>
 <div id="<?php print $wid ?>"></div>
diff --git a/inline/web_widgets_inline_wrapper.tpl.php b/inline/web_widgets_inline_wrapper.tpl.php
index f3e4632..ae8ae33 100644
--- a/inline/web_widgets_inline_wrapper.tpl.php
+++ b/inline/web_widgets_inline_wrapper.tpl.php
@@ -1,10 +1,36 @@
 <?php
-// $Id: web_widgets_inline_wrapper.tpl.php,v 1.1 2009/06/24 07:38:58 aronnovak Exp $
 /**
  * @file
- * Inline embedding means that we include the views output into a javascript file
+ * Inline embedding means that we include the output into a javascript file
  */
 ?>
-window.onload = function() {
-  document.getElementById(widgetContext['widgetid']).innerHTML = <?php print $js_string ?>;
-};
+
+if(typeof addOnloadEvent != 'function') {
+  function addOnloadEvent(fnc){
+    //alert('addOnloadEvent is adding ' + fnc);
+    if ( typeof window.addEventListener != "undefined" ) {
+      //alert(fnc + ' was added as window.addEventListener');
+      window.addEventListener( "load", fnc, false );
+    }
+    else if ( typeof window.attachEvent != "undefined" ) {
+      //alert(fnc + ' was added as window.attachEvent');
+      window.attachEvent( "onload", fnc );
+    }
+    else {
+      if ( window.onload != null ) {
+        var oldOnload = window.onload;
+        window.onload = function ( e ) {
+          oldOnload( e );
+          window[fnc]();
+          //alert(fnc + ' was added to the existing window.onload');
+        };
+      }
+      else
+        window.onload = fnc;
+        //alert(fnc + ' was added as a new window.onload');
+    }
+  }
+}
+addOnloadEvent(function(){
+  document.getElementById(widgetContext_<?php print $id_suffix; ?>['widgetid']).innerHTML = <?php print $js_string ?>;
+});
diff --git a/inline/web_widgets_style_inline.inc b/inline/web_widgets_style_inline.inc
index 98512bb..28b422f 100644
--- a/inline/web_widgets_style_inline.inc
+++ b/inline/web_widgets_style_inline.inc
@@ -42,6 +42,9 @@ function web_widgets_style_inline() {
  * Process variables for web_widgets_inline.tpl.php
  */
 function template_preprocess_web_widgets_inline(&$variables) {
+  $path = parse_url($variables['path']);
+  $path = substr($path['path'], 1);
+  $variables['id_suffix'] = substr(md5($path), 0, 12);
   $variables['wid'] = 'web_widgets_inline_' . md5(microtime());
 
   // Create Javascript variables
@@ -53,6 +56,7 @@ function template_preprocess_web_widgets_inline(&$variables) {
 }
 
 function template_preprocess_web_widgets_inline_wrapper(&$variables) {
+  $variables['id_suffix'] = substr(md5(request_path()), 0, 12);
   $variables['head'] = drupal_get_html_head();
   $variables['styles'] = drupal_get_css();
   $variables['scripts'] = drupal_get_js();
