views:

368

answers:

2

Hi,

I have a web page that I am hosting for a client. The page has the client's header and footer on it and our content (a flash app) placed in the middle.

The client now wants to provide us with an html page that contains their header, footer and some ads all in one document. They want us to include this document as an iframe and then dynamically place OUR content inside of that frame.

This seems very hacky to me but I thought I'd give it a shot. So what's the best way to take my markup and place it into the iframe?

Thanks! Chris

+1  A: 

Can't be done client side because of XSS security issues ... unless they are both on the same domain, but from your description, i doubt it.

Server side, you could dynamically read the target page, modify it any way you wish and then present it. If you really do need it in an iframe, you can dynamically load the modified source you got by something like this:

<html>
<head></head>
<body>
<iframe id="blah"></iframe>
<script>
var doc=document.getElementById("blah").contentDocument;
doc.open();
doc.write("content");
doc.close();
</script>
</body>
</html>

Just remember to also change any links, images, and so on with full URLs.

Rado
A: 

Can you supply them with some API they can use - so they can place something in their page to call your bits. As you are working with flash, you could avoid cross site scripting issues by including a policy file to give permission to their domain.

Sohnee