PDA

View Full Version : Anchor Bookmarks are not working in IFrame when running below script in firefox


ruprup
12-18-2008, 05:23 AM
I am writing html in IFrame with document.write. There are certain bookmarks defined in IFrame document, when we click on this whole IFrame gets refreshed.

Here I am attaching code for testing, please find it in enclosed attachment. To check problem click on Article1 and Article2 links.
You will see that every time the link is created the page is reloaded into the frame but if you see it in IE no suchthing happen.it link it to the name tag
If any one have solution to it please tell


<html>
<head>
<script language="javascript">
function LoadHtml()
{
var strHtml = "<a name=\"Article 1\"></a>";
strHtml += "<a name=\"Article 2\"></a>";
strHtml += "Click Here for <a href=\"#Article 1\">Article1</a>";
strHtml += "Click Here for <a href=\"#Article 2\">Article2</a>";
var objIFrame = document.getElementById("frmEditor");
objIFrame.contentWindow.document.writeln(strHtml);
objIFrame.contentWindow.document.close();

}
</script>
</head>
<body onload="LoadHtml();">
<iframe height="600" width="600" id="frmEditor"></iframe>
</body>
</html>