1
votes

I want to make cross-domain iframe content inside local jquery dialog. When I was developing it in same application everything was fine. When I tryed to test it on another application with another url i get error:

Error: Permission denied to access property ...

I know, there are problems with Security Policy, but I need to make selections inside frame.

Let me show you what I do:
foo/plugin.js:


    var frameDOM;
    function frameLoaded() {
        for (var i = 0; i < window.frames.length; i++) {
            if (window.frames[i].name == "frame-name-here") {
                frameDOM = window.frames[i].document;
                break;
            }
        }
    }

    $(function() {
        var frame = "<iframe src='http://bar:222/Home/frame' id='frame-content' name='frame-name-here' onload='frameLoaded()' />";

    $("#dialog-form").dialog({ autoOpen: true, height: 450, width: 500, modal: true, resizable: false,
                buttons: {
                    "Deliver": function () { //Some long code here
                        }
                }
                create: function (event, ui) {
                    $(this).append(frame);
                }
            });


And after frame is loaded I can easily access to content inside frame:

 $("#frame-input", frameDOM).val();


With cross-domain I lost such possibility. Is there other way to control selectors insode frame, taken from another domain?

P.S. I don't need to Resize frame and that solution didn't helped. I'm looking for alternate way, since this one isn't working.

1

1 Answers

2
votes

Unfortunately, unless you can grab the HTML via PHP or some other scripting language (using cURL in PHP possibly) which would then pass it back to your JavaScript application from the same domain, this is not possible. Please refer to the Same Origin Policy.