Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   Javascript (http://www.velocityreviews.com/forums/f68-javascript.html)
-   -   New to Javascript: How can I automate interaction between framecontents from different domains? (http://www.velocityreviews.com/forums/t939219-new-to-javascript-how-can-i-automate-interaction-between-framecontents-from-different-domains.html)

Ted Byers 08-12-2009 08:08 PM

New to Javascript: How can I automate interaction between framecontents from different domains?
 
If I understand the FAQ correctly, I can't access the contents of one
frame from another frame if they're from different frames.

I believe I can access the contents of a field using what looks like
"document.dialer_form.comments.value"

The dialer is from one domain, and I have created a cgi script that
creates the contents of a second frame. Actually, my prototype web
page has two frames, one of which has a search engine that invokes my
cgi script to produce the contents of a second frame. But right now,
my colleagues that have to use these pages have to have one browser
connected to the dialer's web page, and a second connected to my page,
and they have to copy the contents of one field in the dialer's page
and paste it into a field in my search engine, and pres submit to get
the rest of the data they need. I want to make this faster,
automatic, to reduse the chances of human error. So I thought I would
try to load the dialer's page into a new, third, frame in my page, and
create an event handler so that when the contents of that one field in
the dialer's web page changes, the value is automatically submitted to
my search engine.

If I can't access the contents of a control in the contents of one
frame from another from a different domain, can I do so from the
frameset page that places that content into a frame it contains, to
add the appropriate parameter to the SRC attribute of the other
frame? And if the correct name of the control is what I gave above,
how would that name change if I try to access it from a frameset or
frame that needs it?

If the info I need is in one or more FAQ's, please provide the URL
that will lead me to it. I have been searching through the FAQ at
http://jibbering.com/faq, but I may have missed queries that would be
relevant.

NB: while I have written very little Javascript, I have extensive
experience using Java, C++, Perl, JSP/JSF, ... I am just faced with
an issue now that isn't so easily addressed using the languages I
know.

Thanks in advance for your aide.

Ted

Thomas 'PointedEars' Lahn 08-13-2009 05:41 PM

Re: New to Javascript: How can I automate interaction between framecontents from different domains?
 
Ted Byers wrote:
> If I understand the FAQ correctly, I can't access the contents of one
> frame from another frame if they're from different frames.


If you mean "second-level domain" instead of "frames", you understood correctly.

> I believe I can access the contents of a field using what looks like
> "document.dialer_form.comments.value"


Whereas it should be

document.forms["dialer_form"].elements["comments"].value

provided that the form with name or ID "dialer_form" is in the same
document, that is, it is not located within an (i)frame in the document.
If it were, you would need something along

window.frames[...].document.forms[...].elements[...].value

> The dialer is from one domain, and I have created a cgi script that
> creates the contents of a second frame.
>
> Actually, my prototype web page has two frames, one of which has a search
> engine that invokes my cgi script to produce the contents of a second
> frame.


You appear to be a bit confused about when to use "domain" and when "frame".
Assuming you mean "domain in an (i)frame" instead of "frame" here:

> [...] So I thought I would try to load the dialer's page into a new,
> third, frame in my page, and create an event handler so that when the
> contents of that one field in the dialer's web page changes, the value is
> automatically submitted to my search engine.


ISTM you do not need a third frame as you can add event listeners to the
form in the first frame that shows the dialer. But I could be wrong as I
find your description rather long-winded and (thus) confusing (especially
this summer).

> If I can't access the contents of a control in the contents of one frame
> from another from a different domain, can I do so from the frameset page
> that places that content into a frame it contains, to add the appropriate
> parameter to the SRC attribute of the other frame?


Mu.

(Use transparent proxying to access the other domain's resources.
Note that copyright applies, and take care of XSS.)

> And if the correct name of the control is what I gave above, how would
> that name change if I try to access it from a frameset or frame that
> needs it?


Mu, again.

(The name of the control would not change.) The _referencing_ depends on
where the control is located in relation to the frame. Look into the
`parent', `top', and `frames' properties of Window objects.

> If the info I need is in one or more FAQ's, please provide the URL that
> will lead me to it. I have been searching through the FAQ at
> http://jibbering.com/faq, but I may have missed queries that would be
> relevant.


Possible. What search terms have you used?

The most pertinent document to read in your case, besides section 1.3 of
the FAQ and documents linked there, would probably be
<http://www.catb.org/~esr/faqs/smart-questions.html> (linked in the FAQ
Notes), as the lack of other replies to your posting, but the existence of
replies to newer postings would indicate that other people are having
similar difficulties understanding your posting and answering your questions.

> NB: while I have written very little Javascript, I have extensive
> experience using Java, C++, Perl, JSP/JSF, ... I am just faced with an
> issue now that isn't so easily addressed using the languages I know.


It is not a matter of the programming language but about knowing your
tools (and knowing what you are doing with them). You are dealing with
language-independent DOM APIs in this case.


PointedEars
--
var bugRiddenCrashPronePieceOfJunk = (
navigator.userAgent.indexOf('MSIE 5') != -1
&& navigator.userAgent.indexOf('Mac') != -1
) // Plone, register_function.js:16


All times are GMT. The time now is 10:29 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.