I was wondering if there is any way form me to change 开发者_如何学Cthe contents of an iframe dynamically.
Assuming your iframe is named "frame" (<iframe name="frame">
)
function loadIframe(url)
{
document.all.frame.src=url;
document.all.frame.style.visibility="visible";
}
This allows you to load an URL into there.
If you want to write with javascript into it, you can try
document.all.frame.write("...");
But I don't know if it does work like this, I only know the URL part. Probably does not work, because the iframe is what it is, a frame which displays another document - you could try having a javascript in there that writes what you want. :)
You can change the src
of the iframe to new URL.
精彩评论