1

at the moment i try to figure something out regarding the manipulation of content which is loaded in an IFrame using FancyBox.

First my Situation:

I have my main Page index.php with Standard html, css, etc. and no problems there.

Now i have a file edit.php which contains a link

<a class="various" data-fancybox-type="iframe" href="../index.php">Edit</a>

and the jquery Stuff to load the link in the fancybox:

$(".various").fancybox({

        padding     : 0,
        margin      : 0,
        fitToView   : true,
        width       : '100%',
        height      : '100%',
        autoSize    : false,
        closeClick  : true,
        openEffect  : 'fade',
        closeEffect : 'fade',

    });

This works fine.

What i want to do now is to add some JQuery functionality to the page, which is loaded in the iFrame. My idea was to do something like

$(body).append('<script src="functionality.js" type="text/javascript"></script>');

so i can write my events in functionality.js.

But sadly this does not work.

I think the first problem is that i cannot access the body of the loaded page.

I hope someone can help my solve this problem.

GuRu
  • 1,880
  • 3
  • 23
  • 32
  • Does the domain of the page(s) in the fancybox iframe match that of the parent domain? – Taplar Jan 02 '16 at 22:34
  • Yes. The Files are all on my server with the same domain The Structure is like: mydomain.com/index.php mydomain.com/admin/edit.php –  Jan 02 '16 at 22:37
  • Take a look at the related: http://stackoverflow.com/questions/364952/jquery-javascript-accessing-contents-of-an-iframe – Taplar Jan 02 '16 at 22:38
  • Already read this question, but i don't think that the same origin policy is the problem because it is all the same domain. –  Jan 02 '16 at 22:49
  • No, read further down where it talks about using content() to be able to access the internals of the iframe page, if indeed it is the same origin. – Taplar Jan 02 '16 at 22:50
  • `$(".various").fancybox({ ... afterShow : function(){ $('.fancybox-inner').append(''); } });` after i did this, some simple alert triggert as i opend the fancybox, but now the jquery events which are set in editable.js, cannot be set properly –  Jan 02 '16 at 23:16
  • Do you want that `editable.js` will affect on the container page (`edit.php`) or on the iframe page? Or both of them? – Mosh Feu Jan 03 '16 at 06:55
  • I wann to effect the iframe. –  Jan 03 '16 at 09:06

0 Answers0