2

I have a page which fills the advert formular with the Xing user information. Originally the action will be triggered with a script on my page:

<script type="xing/login">
    {
      "consumer_key": "############"
    }
</script>

The button on the page is a div inside iframe. It functions correctly when the user click the Xing Login button. But now I want the page to trigger the button automatically as soon as the page is loaded with this function:

$(document).ready(function () {
    function tryClickXing() {
        try {
            var iframe = document.getElementsByTagName("IFRAME")[0];
            var doc2 = iframe.contentDocument
            var button = doc2.getElementById("xing-login")
            button.click();
        } catch(e) {
            window.setTimeout(tryClickXing,100)
        }
    }
    tryClickXing();
});

What I get though is

"Uncaught DOMException: Blocked a frame with origin "https://www.xing.com" from accessing a cross-origin frame."

What am I doing wrong?

Jason Aller
  • 3,541
  • 28
  • 38
  • 38
Gazale_m
  • 41
  • 6
  • Possible duplicate of [SecurityError: Blocked a frame with origin from accessing a cross-origin frame](https://stackoverflow.com/questions/25098021/securityerror-blocked-a-frame-with-origin-from-accessing-a-cross-origin-frame) –  Sep 04 '17 at 14:54
  • the iFrame is found after running three times where I set the timeout so the div with the id=xing-login .The only thing which doesnt do anything is button.click() !!!! – Gazale_m Sep 06 '17 at 07:24

1 Answers1

0

Xing has Allowed cross domain click

Access-Control-Allow-Origin: "*"

Now you can do something like this to click a button automatically

$("iframe").contents().find("#xing-login").click();

I have tried this and working fine.

Kashif Hanif
  • 1,718
  • 2
  • 17
  • 29