Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jan 2008
    Posts
    334
    Thanks
    9
    Thanked 0 Times in 0 Posts

    Script crashing browser...

    Hello all. I'm working on a photo upload script. All works well until I added a simple script to get the document body innerHTML so that I could report back to the user if there was any errors or not. So...

    Code:
    		addEvent($('uploaderIframe'),"load",showLoad);
    			}
    			
    			 var showLoad = function() {
    			removeEvent($('uploaderIframe'),"load",showLoad);	
    $('uploaderIframe').src="javascript:window.parent.document.getElementById('uploadInfo').innerHTML = document.body.innerHTML;";
    			}
    		}
    It seems that whenever I try to change src of the iframe it crashes. Not to sure why, as I've seen this be done on other Ajax like Photo upload scripts. Can I get some help with this please...


    Here's the full script:
    Code:
    		function addEvent(obj, evType, fn){
    			if(obj.addEventListener)
    				obj.addEventListener(evType, fn, true)
    			if(obj.attachEvent)
    				obj.attachEvent("on"+evType, fn)
    		}
    
    		function removeEvent(obj, type, fn){
    			if(obj.detachEvent){
    				obj.detachEvent('on'+type, fn);
    			}else{
    				obj.removeEventListener(type, fn, false);
    			}
    		}
    
    		function ajaxPhotoUploader() {
    			document.getElementById('file_upload_form').onsubmit=function() {
    			if($('uploaderIframe')) {
    				document.getElementById('file_upload_form').removeChild(document.getElementById('uploaderIframe'));
    			}
    				$('uploadInfo').innerHTML = '<img src="./images/ajax-loader.gif" />';
    				if(window.ActiveXObject) {
    				var iframe = document.createElement("<iframe id=\"uploaderIframe\" name=\"uploaderIframe\" src=\"./uploadto.php\" style=\"width:200px;height:200px;\">");
    				}
    				else {
    				var iframe = document.createElement("iframe");
    				iframe.setAttribute("name","uploaderIframe");
    				iframe.setAttribute("src","./uploadto.php");
    				iframe.setAttribute("id","uploaderIframe");
    				
    				}
    				document.getElementById('file_upload_form').appendChild(iframe);
    				document.getElementById('file_upload_form').target = 'uploaderIframe'; //'uploaderIframe' is the name of the iframe
    				addEvent($('uploaderIframe'),"load",showLoad);
    			}
    			
    			 var showLoad = function() {
    			removeEvent($('uploaderIframe'),"load",showLoad);	
    $('uploaderIframe').src="javascript:window.parent.document.getElementById('uploadInfo').innerHTML = document.body.innerHTML;";
    			}
    		}
    Thanks,
    Jon W
    Last edited by Jon W; 06-08-2010 at 08:38 PM.

  • #2
    Senior Coder tomws's Avatar
    Join Date
    Nov 2007
    Location
    Arkansas
    Posts
    2,644
    Thanks
    29
    Thanked 330 Times in 326 Posts
    You're using Firebug to check Javascript errors, right? What's it saying?
    Are you a Help Vampire?

  • #3
    Regular Coder
    Join Date
    Jan 2008
    Posts
    334
    Thanks
    9
    Thanked 0 Times in 0 Posts
    Nope, I'm not using firebug to check for errors. Never thought about to be honest. Firefox isn't the one that is crashing really anyways. Google Chrome is the only one that seems to be crashing.

    Edit:

    However it is messing up. It seems to be refreshing the iframe none. So it's almost as if it gets stuck in a loop.
    Last edited by Jon W; 06-08-2010 at 09:11 PM.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •