tags:

views:

350

answers:

3

Hi,

I'm new to javascript so please excuse if this question is trivial. I have a dynamic Webpage that includes an iFrame where external html Code is included. Now I need to dynamically remove an element from this iFrame.

Firebug give's me the following XPath Entry for the Element.

/html/body/div[2]/div[2]/ol/table/tbody/tr/td/a/img

My question now is how can I transform this into a DOM Element Structure to create a Javascript which will remove the element. Or is there any other way to remove this image ?

Thanks indeed

[EDIT]

The source of the iFrame is created by another webserver. We generate it there because of load sharing.

A: 

I may be misguided here, but I believe you will start to run into strange problems ( I had a similar experience) when trying to manipulate Iframes with Javascript. It boils down to the same-origin policy. Basically you can not write a script that manipulates content from a different source. This makes sense most of the time for obvious security reasons. This may not be the cause of your problems but keep it in the back of your mind.

see http://en.wikipedia.org/wiki/Same_origin_policy

darren
A: 

Is the HTML loaded from an external domain? If that is the case, you can't work on the DOM tree for security reasons. Read more in this blog post (which also have some hacks for simple communicaiton, but nothing that can be used for manipulating the DOM):

http://softwareas.com/cross-domain-communication-with-iframes

Emil Vikström
A: 

You will either need to change your network so that both domains are the same (and load balance behind the domain rather than in front of it) OR, use a framework such as easyXDM to communicate across domains.

Graza