PDA

View Full Version : Frame Problem ...in IE



pankaj.ghadge
10-16-2008, 01:59 PM
I have taken 2 frames..........
One is left.html and right.html
In right hand side frame I have taken text box and on an Enter press it call the function written in left hand side. ................
and adds the value in left hand side Div tag on Enter key press Event.................

The code is as follows
---------------------------------------------------------------------------------------------------------
main.html
<html>
<head>
</head>
<frameset cols="15%, *" id="fs1">
<frame src="left.html" name="left" frameborder="1" id=leftId>
<frame src="right.html" name="right" frameborder="1" id=leftId>
</frameset>
</html>

left.html
<html>
<head>
<link rel="stylesheet" href="test.css" type="text/css" />
<script>
function Entry(evt,txtID)
{
var charCode = (evt.which) ? evt.which : event.keyCode;
//At this statement IE does not recognize which event is fired and firefox recognize it
if(charCode==13) // if Enter key is pressed
{
var txtObj=parent.right.document.getElementById(txtID);
if(txtObj.value=="")
return;
divObj=document.getElementById("divID");
divObj.innerHTML=divObj.innerHTML+txtObj.value+"<br>";
txtObj.value="";
}
}
</script>
</head>
<body>

<div id="divID"></div>

</body>
</html>

right.html
<html>
<body>
<input type=text id="entryID" onkeypress="parent.left.Entry(event,this.id)";>
</body>
</html>
-------------------------------------------------------------------------------------------------------
It works well in mozilla but not in IE
so please tell me...........................
I need U R help.................................

rangana
10-17-2008, 01:35 AM
I'm surprised that it works in FF.

Anyway, try to transfer the script from left.html to right.html and change script to:


function Entry(evt,txtID)
{
var charCode = (evt.which) ? evt.which : event.keyCode;
//At this statement IE does not recognize which event is fired and firefox recognize it
if(charCode==13) // if Enter key is pressed
{
var txtObj=document.getElementById(txtID);
if(txtObj.value=="")
return;
divObj=parent.left.document.getElementById("divID");
divObj.innerHTML=divObj.innerHTML+txtObj.value+"<br>";
txtObj.value="";
}
}


Highlighted are slight changes.

Hope it helps.