[Javascript] detecting a frame with a field

Terry Riegel riegel at clearimageonline.com
Fri Oct 15 10:32:15 CDT 2004


Matt,

Thats pretty cool. The documents are running on the same domain, I just 
have no control over the one. Your script works as fine, but I have a 
small problem. Here is your script with my modifications.

Notice, I have it do an alert when the form element shows up. That is 
working except the alert keeps popping up continually. Is there a way 
to have it only alert once?

<script language="JavaScript">
<!--
function fCheckFrame() {
   oRightHandDocument = parent.dbconsole.panelwindow.document;
   aElements = oRightHandDocument.getElementsByName ('CO_USERNAME');
   if (aElements.length > 0) {
     alert('hello the form is there now.');
   }
}
window.setInterval (fCheckFrame, 100);
-->
</script>


Terry Riegel

Put Your TimeClock on the Web
http://www.punchedin.com
On Oct 15, 2004, at 5:05 AM, Matt Barton wrote:

> Morning Terry,
>
> You'll have difficulties if the documents in the two frames are served 
> from different domains - you'll get "Access Denied" errors in 
> javascript when trying to access the right-hand frame.
>
> I know that you haven't said that they are below, but when you said 
> that the right hand frame wasn't under your control, I thought that 
> might have been one of the possibilities.
>
> Assuming that the two documents are from the same domain however, I 
> suppose you could use the setInterval () method of the left hand 
> window to call a function every so often which checks the right hand 
> frame. The function could use the getElementsByName method of the 
> document in the right hand window.
>
> Something like:
>
> // ------------
> function fCheckFrame () {
>   oRightHandDocument = parent.idOfRightHandFrame.document;
>   aElements = oRightHandDocument.getElementsByName ('CO_USERNAME');
>   if (aElements.length > 0) {
>     document.forms[0].submit ();
>   }
> }
>
> window.setInterval (fCheckFrame, 100);
> // -------------
>
> You would need to know the ID and/or name of the right hand frame, but 
> you'll have control over that won't you? Also you'd need to customise 
> the reference to your form - I just used form[0] to reference the 
> first (only) form in the document in my test case.  I've tested this 
> in IE6/Win and Firefox and both are OK.
>
> Hope this helps a little.  I'd be interested to see if anyones got a 
> better method of triggering the check of the right hand frame, as I 
> don't particularly like window.setInterval - it strikes me as (in this 
> instance) a little inelegant.
>
> Ta ta,
>
> Matt
>
> Terry Riegel wrote:
>> Hello All,
>> I have set up a 2 frame page. The left frame is fully under my 
>> control, the right frame is not.
>> +--+------+
>> |  |      |
>> |  |      |
>> |  |      |
>> +--+------+
>> I want the left frame to watch the right frame until it contains a 
>> form with a text field named CO_USERNAME
>> The Right frame (I can't control its contents) will look like below.
>> <body>
>> <form method=post action=http://www.page.com>
>> ...
>> <input type=text name=CO_USERNAME size=30 maxlength=30 
>> value="Visitor5">
>> ...
>> </form>
>> </body>
>> When the left frame sees a text field labeled CO_USERNAME it will 
>> trigger a page load.
>> Can this be done?
>> Terry
>> _______________________________________________
>> Javascript mailing list
>> Javascript at LaTech.edu
>> https://lists.LaTech.edu/mailman/listinfo/javascript
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: text/enriched
Size: 3514 bytes
Desc: not available
URL: <http://lists.evolt.org/pipermail/javascript/attachments/20041015/66213efa/attachment.bin>


More information about the Javascript mailing list