tags:

views:

44

answers:

2

I am digging deep into a page's DOM to manipulate a certain image attribute. I have a web page which contains an iFrame. The iFrame contains an image. The image has no id attribute so I am going to locate it using it's src. The src contains the unique keyword 'planet'. How do I locate this image using jQuery?

ADDITION:

I can't reference anything in the iFrame's DOM. Is there a special way to reference an element inside an iFrame?

Example: alert( $(myIframe).find('html').length ) reports 0, expecting 1.

A: 

$(function() { var img = $('iframe img[src|=planet); });

Jeff T
+1  A: 

I don't think you can manipulate iframe contents if the iframe's domain is not one you have control over.

EDIT: Since you said that it IS from the same domain now, $('#id').contents().find('a') should work.

meder
+1 you can't it breaks the security model of browsers. see http://msdn.microsoft.com/en-us/library/ms533028%28VS.85%29.aspx
Wes
IFrame source is from the same site. It's actually ASP.NET's report viewer.
Tony_Henrich
Edited my answer based on this.
meder