Forum Moderators: open
I need the below code work for onClick event. It simply dosent work, I could not figure out why,
Try to type in some thing in the iframe and click on the fontsize 20 to see what i mean.
please help :(
Lalith
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<script language="JavaScript">
function Init()
{
document.getElementById("edit").contentWindow.document.designMode = 'On';
}
function setfont()
{
document.getElementById('edit').contentWindow.document.execCommand('fontsize', false, 6);
}
</script>
<body onLoad="Init()">
<table>
<tr><td onMouseDown="setfont();" style="cursor:pointer; text-decoration:underline;">FontSize 20</td><td>This work if I use onMouseDown or onMouseOver or onMOuseOut</td></tr>
<tr><td onClick="setfont();" style="cursor:pointer; text-decoration:underline;">FontSize 20</td><td>This dosent work if I use onClick or onMouseUp</td></tr>
</table>
<iframe id="edit" name="edit" style="width: 100%; height:370px; border:1px none #d9d9d9;"></iframe>
</body>
</html>
I suspect it's more that the TD elements are not responding to the events while hyperlinks are. Play around with the links, changing the onclick to onmousedown and onmouseup to see what happens. You'll rarely need those events, but just so you know.