Target and alter <iframe> contents from another domain

Hi everyone,

I’ve had a good look around and I’m getting the impression that this isn’t possible.

I want to add some classes to various bits on one of Worldpay’s lovely :goof: payment iframes so I can make it look something like the site it’s sat on.

This is the original principle I was using, which works when on a page with the same domain.

$('#worldpay').load(function(){
		                    $(this.contentDocument).find('body').html('Test: This frame was modified with js')

});

Any ideas?

If the iframe is being sourced through a domain than the current page url then the browser will not let you interact with the content of the iframe in anyway. To get around this the iframe source needs to be on the same domain, if you really want to do this then you can use a server side script to proxy the iframe source through your own domain. This brings it’s own risks but allows you to manipulated the contents of the iframe.

If you want to read more on why browsers disallow this kind of behaviour:
Cross-site scripting - Wikipedia, the free encyclopedia

Thanks, I’ll look into it : )