Cross Frame AJAX Scripting Using Iframes
I'm not sure how many of you are doing AJAX development, but this may be helpful to someone.
I have been working on a fun project at my full-time job, and came across a difficult situation: I needed to update the parent frame's form from a child iframe, and needed to still use the prototype javascript library shortcuts.
Here's what I mean:
Parent page --
<html>
<head>
<script src='prototype.js'... ></script>
<script>
Form.disable('myform');
</script>
</head>
<body>
<iframe ... ></iframe>
<form id='myform' name='myform' ... >
...
</form>
</body>
</html>
Iframe --
<html>
<head>
<script src='prototype.js'... ></script>
<script>
Form.enable('myform');
</script>
</head>
...
As you can see the above will not work because 'myform' is not in the current document but in the parent. So my workaround is this:
Form.enable(parent.document.forms['myform']);
Now I can access the DOM of the parent by using the 'parent' element. Works slick and I can use all of the Prototype library elements in this method.
Quite nice for lazy sods.
Thanks,
Sean
