Avatar of codevomit
codevomit
 asked on

Remove an element from an iFrame in IE6

Hi,

I need to remove an element from an iFrame in IE6, adding them is not a problem, removing is. I've tried all manor of code from the internet with no prevail, I even attempted to attempted to call a javascript function that inside the iFrame , works on other browsers but not IE6.
JavaScript

Avatar of undefined
Last Comment
leakim971

8/22/2022 - Mon
HainKurt

post a small sample that shows how you add, and the code you tried to remove it... so we can fix it...
leakim971

var ref = document.getElementById("iframe_ID").document.getElementById("your_Element_ID");
or
var ref = document.getElementById("iframe_ID").document.getElementsByTagName("TAG_OF_ELEMENT")[INDEX_OF_YOUR_ELEMENT_IN_THE_DOM];

and use :

ref.parentNode.removeChild(ref);
HainKurt

a test script for what leakim971 posted above...
<script>
function test(elm){
  var e = document.getElementById(elm);
  if (e) e.parentNode.removeChild(e); 
}
</script>

<ul>
<li id=liTest1>A
<li id=liTest2>B
<li id=liTest3>C
</ul>

<button onclick="test('liTest1')">Remove A</button>
<button onclick="test('liTest2')">Remove B</button>
<button onclick="test('liTest3')">Remove C</button>

Open in new window

This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
codevomit

ASKER
HainKurt, I think you may of missed the point, i'm having problem from removing an element that's contained within an iFrame using IE6.
codevomit

ASKER
leakim971 I have tried those alread but they do not seem to work with IE6
SOLUTION
leakim971

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER CERTIFIED SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
leakim971

parent :
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<script>
	window.onload = function() {
		var iframe = document.getElementById("iframe_ID");
		var doc = (iframe.contentDocument)?iframe.contentDocument:iframe.contentWindow.document;
		ref = doc.getElementById("your_Element_ID");
		ref.parentNode.removeChild(ref);
	}
</script>
<body>
<iframe id="iframe_ID" width="320px" height="200px" src="child.html"></iframe>
</body>
</html>

Open in new window

child.html :
<html>
<body>
<H3 id="your_Element_ID">codevomit</H3>
</body>
</html>

Open in new window

Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
codevomit

ASKER
leakim971's first answer pointed me in the right direction.
leakim971

Why 250 points? ID:36357086 is a working solution (and it come before your ID:36357125)