Accessing elements in an iframe

A word about interaction between DOM objects in master view (website) and slave view (iframe).

For getting value from iframe view, by code put into parent view, this seems to be easy. I’ve tried example from jQuery’s docs — using .contents() method:

alert($("#patient-iframe").contents().find("Patient_PESL").val())

You should only notice, that if you inject code for this kind of manipulation directly into buttons array, this might fail in many situations, with browser (tested in IE, FF and Chrome) reporting an error saying:

h.apply is not a function in: assets/7126e48d/jui/js/jquery-ui.min.js line: 337

As I wrote in a comment to CJuiDialog, a simple workaround for this problem, is to move necessary code to a separate JS function and only put call to that function directly into CJuiDialog.options.buttons array.

In these articles, forum topics or blog posts you’ll find some solutions, how to do this when not using jQuery:

The last one also contains long, detailed explanation and introduction into iframes in general.

This forum topic is somewhat similar and you may find some interesting information, if you’re using iframes.

Leave a Reply