You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@wicket.apache.org by iv...@apache.org on 2009/08/07 18:31:57 UTC

svn commit: r802080 - /wicket/sandbox/ivaynberg/wicket-ajax-multipart/src/main/java/org/apache/wicket/ajax/wicket-ajax.js

Author: ivaynberg
Date: Fri Aug  7 16:31:57 2009
New Revision: 802080

URL: http://svn.apache.org/viewvc?rev=802080&view=rev
Log:
now works with crappy explorer 8
Issue: WICKET-2420

Modified:
    wicket/sandbox/ivaynberg/wicket-ajax-multipart/src/main/java/org/apache/wicket/ajax/wicket-ajax.js

Modified: wicket/sandbox/ivaynberg/wicket-ajax-multipart/src/main/java/org/apache/wicket/ajax/wicket-ajax.js
URL: http://svn.apache.org/viewvc/wicket/sandbox/ivaynberg/wicket-ajax-multipart/src/main/java/org/apache/wicket/ajax/wicket-ajax.js?rev=802080&r1=802079&r2=802080&view=diff
==============================================================================
--- wicket/sandbox/ivaynberg/wicket-ajax-multipart/src/main/java/org/apache/wicket/ajax/wicket-ajax.js (original)
+++ wicket/sandbox/ivaynberg/wicket-ajax-multipart/src/main/java/org/apache/wicket/ajax/wicket-ajax.js Fri Aug  7 16:31:57 2009
@@ -1083,44 +1083,55 @@
 		var originalFormAction=form.action;
 		var originalFormTarget=form.target;
 		
-		var iframe=document.createElement("iframe");
+		var iframeName="wicket-submit-"+Math.random();
+		
+		var iframe=null;
+		try {
+    		iframe = document.createElement("<iframe name='"+iframeName+"' id='"+iframeName+"' src='about:blank'/>");
+		} catch (ex) {
+		    iframe = document.createElement("iframe");
+		    iframe.name=iframeName;
+			iframe.id=iframe.name;
+			iframe.src="about:blank";
+		}
+		
 		
 		//iframe.style.width="600px";
 		//iframe.style.height="300px";
 		iframe.style.display="none";
 		iframe.style.visibility="hidden";
-		
-		iframe.name="wicket-submit-"+Math.random(); // TODO make sure this is unique
-		iframe.id=iframe.name;
-		iframe.src="about:blank";
-		
+				
 		Wicket.Event.add(iframe, "load", this.handleMultipartComplete.bind(this));
 		
 		document.body.appendChild(iframe);
 		
 		// reconfigure the form
-		form.target=iframe.name;
-		form.action=this.request.url;
+		form.setAttribute("target",iframe.name);
+		form.setAttribute("action",this.request.url);
 
 		//submit the form into the iframe, response will be handled by the onload callback
 		form.submit();
 
 		// handled, restore state and return true
-		form.action=originalFormAction;
-		form.target=originalFormTarget;
+		form.setAttribute("action",originalFormAction);
+		form.setAttribute("target",originalFormTarget);
 		
  		return true;
  	},
  
  	// Completes the multipart ajax handling started via handleMultipart()
 	handleMultipartComplete: function (event) {
-		var iframe=event.target;
+		if (event==null) { event=window.event; }
+		if (event.target!=null) { var iframe=event.target; } else { var iframe=event.srcElement};
 
+		var envelope=iframe.contentWindow.document;
+		if (envelope.XMLDocument!=null) { envelope=envelope.XMLDocument; }
+	
 		// process the response
-		this.loadedCallback(iframe.contentWindow.document);
+		this.loadedCallback(envelope);
 
 		// stop the event
-		if (event.stopPropagation) { event.stopPropagation(); } else {event.cancelBubble=true;}
+		if (event.stopPropagation) { event.stopPropagation(); } else { event.cancelBubble=true; }
 
 		// remove the event
 		if (iframe.detachEvent)