0

I've found here in SO these two ways to manipulate css style od div elements inside an iframe:

jQuery("iframe").contents().find(".rc-anchor-normal-footer").css("margin-left", "-60px");

and

jQuery("iframe").load(function() {
    var doc = this.contentDocument || this.contentWindow.document;
    var ancor_footer = document.getElementsByClassName("rc-anchor-normal-footer");
    ancor_footer[0].style.marginLeft = "-60px";
});

They both were put inside the jQuery(document).ready(function(){}) but none of them works. If i try to give those commands inside firebug JS console I get

jquery.js?ver=1.12.4:2 Uncaught DOMException: Failed to read the 'contentDocument' property from 'HTMLIFrameElement': Blocked a frame with origin "http://www.pasticceriaimpero.com" from accessing a cross-origin frame.

even if I had set

document.domain = "www.pasticceriaimpero.it"

Wham am I supposed to do to make it work?

UPDATE I managed to manipulate g-recaptcha style with the following:

@media not screen and (max-aspect-ratio: 3/4) {
.g-recaptcha {
  margin-top: 2px !important;
  transform:scale(0.78);
  transform-origin:0 0;
}

and witout accessing every single sub div of the recaptcha with jQuery...

SagittariusA
  • 5,289
  • 15
  • 73
  • 127
  • You can't change **anything** inside an iFrame that loads a page where domain, port or protocol does not match the parent page, it's called the same-origin policy. – adeneo Oct 25 '16 at 08:14
  • If your domain is NOT pasticceriaimpero.it which is what you need to set, then it is wishful thinking. visit https://developer.mozilla.org/en-US/docs/Web/API/Document/domain and https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy – mplungjan Oct 25 '16 at 08:14
  • Maybe I forgot to say that the div I would like to change is Google recaptcha `
    – SagittariusA Oct 25 '16 at 08:16
  • 1
    This https://developers.google.com/recaptcha/old/docs/customization can help? – Germano Plebani Oct 25 '16 at 09:11
  • Thank you mate. I'm going to have a look! :) – SagittariusA Oct 25 '16 at 09:12
  • 2
    Ops too fast, http://stackoverflow.com/questions/27713505/recaptcha-api-v2-styling – Germano Plebani Oct 25 '16 at 09:13

0 Answers0