Results 1 to 2 of 2

Thread: Frame Problem ...in IE

  1. #1
    Join Date
    Oct 2008
    Posts
    40
    Thanks
    3
    Thanked 1 Time in 1 Post

    Smile Frame Problem ...in IE

    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.................................

  2. #2
    Join Date
    Feb 2008
    Location
    Cebu City Philippines
    Posts
    1,160
    Thanks
    17
    Thanked 277 Times in 275 Posts

    Default

    I'm surprised that it works in FF.

    Anyway, try to transfer the script from left.html to right.html and change script to:
    Code:
    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.
    Learn how to code at 02geek

    The more you learn, the more you'll realize there's much more to learn
    Ray.ph!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •