Close

Results 1 to 7 of 7
  1. #1
    DF VIP Member
    canardo's Avatar
    Join Date
    Jul 2001
    Location
    uk
    Posts
    840
    Thanks
    0
    Thanked:        0
    Karma Level
    322

    Default html javascript dom removing a tag

    HI there if I had something like the following

    Code:
    <div id="myFrame">
         <iframe id="uploadIframe"> </iframe>
    </div>
    I want to remove uploadIframe and replace it with another
    at the moment the only way I can find to do it is to have a css class that sets the visibility and width height to 0 is it possible using some javascript to actually remove the iframe tag

  2. #2
    DF VIP Member BBK's Avatar
    Join Date
    May 2006
    Location
    here
    Posts
    12,422
    Thanks
    234
    Thanked:        128
    Karma Level
    1084

    Default Re: html javascript dom removing a tag

    man, I've done this, so it can definitely be done. Sorry, but at the moment I can't find the code that did it, and I'm not good enough to figure it out easily

  3. #3
    DF VIP Member salvadorescobar's Avatar
    Join Date
    Dec 2000
    Location
    Huddersfield
    Posts
    951
    Thanks
    0
    Thanked:        0
    Karma Level
    346

    Default Re: html javascript dom removing a tag

    can't you just set the element within the DOM to whatever you want provided the type fits?

    var currentIFrame = document.getElementById("uploadIFrame");

    currentIFrame = newIFrame;

    Or something like that?
    'If we aren't meant to eat animals, then why are they made out of meat?'
    Anon.

  4. #4
    DF VIP Member hxbro's Avatar
    Join Date
    Nov 2000
    Location
    Behind a wall
    Posts
    2,731
    Thanks
    4
    Thanked:        18
    Karma Level
    476

    Default Re: html javascript dom removing a tag

    or maybe just overwrite the innerHTML of myFrame would work
    Download my latest breaks and electro mixes or listen to Sellout Breaks FM

  5. #5
    DF Rookie Kerry-Exile's Avatar
    Join Date
    Nov 2006
    Location
    Swansea
    Posts
    13
    Thanks
    0
    Thanked:        0
    Karma Level
    0

    Default Re: html javascript dom removing a tag

    Quote Originally Posted by hxbro View Post
    or maybe just overwrite the innerHTML of myFrame would work
    That would be the best way to do it, we do stuff like that now, have your have a javascript function that will display the html you want depending on the option in your div

  6. #6
    DF Rookie Kerry-Exile's Avatar
    Join Date
    Nov 2006
    Location
    Swansea
    Posts
    13
    Thanks
    0
    Thanked:        0
    Karma Level
    0

    Default Re: html javascript dom removing a tag

    ie

    function showIFrame()
    {
    var myIFrame = document.getElementById("uploadIFrame");
    var strHTML = "<iframe>";
    strHTML += "<table>whatever iframe content</table>";
    strHTML += "</iframe>";
    myIFrame.innerHTML = strHTML;
    }

    That way you can change it on the fly

  7. #7
    DF VIP Member
    canardo's Avatar
    Join Date
    Jul 2001
    Location
    uk
    Posts
    840
    Thanks
    0
    Thanked:        0
    Karma Level
    322

    Default Re: html javascript dom removing a tag

    cheers for the advice guys I was being a bit of a tard and am tryign to create an upload box so that you dont have to page refresh or wait for it to upload by using the iframe.submit method

    have done it like so

    Code:
    <script language="javascript">
    		function upload()
    		{
    		
    			// hide old iframe
    			var par = window.parent.document;
    			var iframe = par.getElementById('uploadFrame');
    			iframe.className = 'hidden';
    			iframe.height='0px';		
    			alert("hidden old iframe");
    	
    			
    			// create new iframe
    			var new_iframe = par.createElement('iframe');
    			new_iframe.src = 'upload.php';
    			new_iframe.frameBorder = '0';
    			new_iframe.width= '202px';
    			par.getElementById('iframe').appendChild(new_iframe);
    			
    			alert("new iframe created");
    					
    			//setTimeout(document.iform.submit(),5000);	
    			document.iform.submit();
    			
    			
    			
    			/*
    			data_grid.fetchBuffer(0, false, true);
    			data_grid.requestContentRefresh(0, true);
    			*/
    		}
    		</script>
    
    CSS Looks like this
    #iframe {
    	border-width: 0px;
    	height: 120px;
    	width: 203px;
    	background: url('../images/assetLibrary/gui_nu_library_base.png');
    
    }
    		
    .hidden {
    	visibility: hidden;
    	width:0px;
    	height:0px;
    
    }
    
    HTML Looks like this
    
    <div id='iframe'>
    				
    				<iframe src="upload.php" id="uploadFrame" frameborder='0' width="202px" ></iframe>
    </div>
    
    IFrame code looks like this
    
    <form name="iform" action="" method="post" enctype="multipart/form-data">
    		
    		<div id="imageAddToLibraryBrowseButton">
    			<input type="file" class="file" name="fileUpload" onChange="upload()"/>
    			<div id="fakefile">					
    				<img src="images/assetLibrary/BrowseButton.png" alt = "BrowseButton" />				
    			</div>			
    		</div> 	
    		
    	</form>
    Last edited by canardo; 14th November 2006 at 02:54 PM.

Similar Threads

  1. Palm os + html editor
    By digidump in forum PC Software
    Replies: 0
    Last Post: 20th November 2002, 02:15 PM
  2. Javascript problem....
    By g1bbo in forum Website Coding & Graphics
    Replies: 4
    Last Post: 12th November 2002, 10:42 AM
  3. Removing Hotpoint Brushes
    By colinjohn1 in forum The Dog and Duck
    Replies: 4
    Last Post: 8th October 2002, 10:32 AM
  4. removing tar!
    By EUPHORiA in forum Cars & Motorbikes
    Replies: 6
    Last Post: 14th September 2002, 09:21 PM
  5. Removing BIOS password from Sony V910
    By Tattooed Freak in forum PC Problems
    Replies: 3
    Last Post: 2nd September 2002, 09:09 PM

Social Networking Bookmarks

Posting Permissions

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