"ok" <a@b.c> wrote in message news:<41******@news01.argolink.net>...
<img src="http://www.6park.com/enter2/av.gif" onload="document.write('an
iframe obj');">
This is a strange directive. What you are saying is that when the
image gets loaded from the server, you want run the function
document.write. Assuming for a moment that document.write might do
something valid, it would insert into the document the phrase 'an
iframe obj'. Document.write takes as input normal html.
You would expect something like:
document.write("<iframe src='myiframe.html'><\/iframe>");
However, this wouldn't work in your situation.
It would appear that you are trying to set a message in the page when
the loading of the image is complete.
First of all, it destroy the HTML page.
How true. Document.write is designed to be used as the html is being
constructed. Once a web browser see the </html> tag, you can no
longer use the document.write function.
How do I write a new iframe obj outside img tag?
I assumed you were using the image as a button and wrote the follow
code. When I wrote the code, I didn't realize that you where using
the onload event handler. I assumed onclick. To change to the onload
do something like:
<img src="http://www.6park.com/enter2/av.gif"
onload="insertIframe();">
Notice that I have a div where the iframe will be inserted.
I tested this with macos 10.2.6 with IE 5.2 and netscape 7.3.
Robert
insert.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>insert an iframe</title>
<script type="text/javascript">
function insertIframe ()
{
var node;
if (document.getElementById)
{
node = document.getElementById("iframediv");
if (node)
{
var myElement = document.createElement("DIV");
node.appendChild(myElement);
myElement.innerHTML =
"<iframe src='myiframe.html' " +
"width='400' height='160'></iframe> " ;
}
else
{
alert("The function insertIframe could not find " +
"the tag iframediv.");
return;
}
}
else
{
alert(" document.getElementByID failed. " );
return;
}
}
</script>
</head>
<body>
<p>Insert an iframe.
<br>
Don't forget to see what happens when you
press the button more than once.</p>
<form>
<input type="button"
name="activate"
value="insert the iframe"
onclick="insertIframe();">
<br>
</form>
<div id='iframediv'>
</div>
</body>
</html>
myiframe.html
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>this is myiframe</title>
</head>
<body>
<p>This iframe was inserted by innerHTML.
<br>
This is amazing!</p>
</body>
</html>