PDA

View Full Version : multiple iFrame - get the one in focus??


homerUK
03-05-2003, 10:15 PM
hey,

I have 4 iFrames on a page... is there any way I can detect which one the user is currently editing or has an active selection?

Its for a WYSIWYG tool bar.... so if the user is in iFrame1 and they highlight some text then press "bold" I want it to update the iframe1 selection.....

I was thinking something like

theSelection = document.[get the iframe].selection;

any ideas?!

thanks!!

chrismiceli
03-05-2003, 10:38 PM
try this link, it was posted a while ago about telling if an input field has focus
http://www.codingforums.com/showthread.php?threadid=11460&highlight=focus+where

homerUK
03-05-2003, 11:30 PM
cheers for that, it helped a little.... but here is some code I have made as a result of reading that post....

I have a function called "check()" which is called when the form is submitted.....


//check

function check()
{

alert(theframe)

return false;

}


then I set the iFrames:


<form name="form" onsubmit="return check()">
<input type="submit" name="Submit" value="do it">
<iframe height="200" width="60" id="frame1" onfocus="theframe='frame1'"></iframe>
<iframe height="200" width="60" id="frame2" onfocus="theframe='frame2'"></iframe>
</form>


basically what I want to happen is that when the button is pressed, check() is called.... then that will popup with the iFrame which currently is selected......

any more ideas to that?!

many thanks...... :thumbsup:

chrismiceli
03-06-2003, 12:57 AM
you might want to do this, make theframe a global variable, i don't think it is there,
<script type="text/javascript">
theframe="";
function ....
</script>

homerUK
03-06-2003, 09:33 AM
hey.... that works perfectly now!!

Cheers guys!!! :thumbsup: :thumbsup: