I have attempted to, but so far have been unable to confirm that I have done
it successfully.
var oIframe = document.getElementById("if");
var oDoc = oIframe.contentWindow || oIframe.contentDocument;
if (oDoc.document) {
oDoc = oDoc.document;
}
//add jquery to iframe
var s=document.createElement('script');
s.setAttribute('src','http://localhost/js/jquery.js');
oDoc.body.appendChild(s);
(localhost is because I'm testing on my local system using xammp)
Sam Collett wrote:
>
> On 14/02/07, 15daysofjquery <[EMAIL PROTECTED]> wrote:
>>
>> How do I target an element inside of an iframe I've created on the page?
>> In
>> other words, I've used jQuery to create an iframe, and now I need to
>> target
>> all the p elements of the document inside that iframe.
>>
>> I've tried
>>
>> $("p",self.MyIFrame.document).click(function(){alert('asdf');});
>>
>> and also
>>
>> $("p",oIframe).click(function(){alert('asdf');});
>>
>> where oIframe is
>> var oIframe = document.getElementById("if");
>>
>> The frame generated by jquery is straightforward:
>>
>> $('div#results').empty().append('<iframe src="'+t+'" frameborder="1"
>> width="90%" height="300px" id="if" name="MyIFrame"></iframe>');
>>
>> Thanks.
>>
>> --
>
> Have you included jQuery in the target frame?
>
> _______________________________________________
> jQuery mailing list
> [email protected]
> http://jquery.com/discuss/
>
>
--
View this message in context:
http://www.nabble.com/Target-iframe-generated-by-jquery-tf3227636.html#a8988206
Sent from the JQuery mailing list archive at Nabble.com.
_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/