1

I want to pre populate a field on an embedded form. The field in question has the name property of "productname". I want to use the text content of an h2 element on the same page the has the class .djc_title . This code was working until recently. It appears that the embed code of my form is now referencing a different source for javascript and my code now gives me this error in the console.

DOMException: Blocked a frame with origin "http://www.example.com" from accessing a cross-origin frame. at fa.getText >>(http://www.example.com/media/jui/js/jquery.min.js:2:13026)

And here is the offending code:

onFormReady: function() {
  var this_text = $(this).text();
  var h2c_djc_title = $('h2.djc_title').text().trim(this_text)
  var result = $('input[name="productname"]').val(h2c_djc_title);
}

Is there a better way to achieve the same result?

jmunsch
  • 22,771
  • 11
  • 93
  • 114
Matt Martin
  • 51
  • 1
  • 3
  • 1
    Why can't you just set the default in the HTML? – Thomas Juranek Dec 21 '16 at 19:17
  • 2
    Is the embedded form in an iframe? If the main page and the iframe are in different domains, the main page can't manipulate the contents of the iframe. – Barmar Dec 21 '16 at 19:19
  • 1. Replace `jQuery` for `$` for better readability. 2. Are you using an iframe? –  Dec 21 '16 at 19:20
  • possibly: http://stackoverflow.com/questions/25098021/securityerror-blocked-a-frame-with-origin-from-accessing-a-cross-origin-frame – jmunsch Dec 21 '16 at 19:20
  • Was the browser updated to a more recent version? There could have been an update to the browser's [same origin policy](https://en.wikipedia.org/wiki/Same-origin_policy) – Tom O. Dec 21 '16 at 19:29
  • @ Thomas Juranek - I don't know what you mean. What default? – Matt Martin Dec 21 '16 at 20:52
  • Also, I can't use $ because it conflicts with another framework in my CMS so I have to use " jQuery" – Matt Martin Dec 21 '16 at 20:53
  • One of the pages in question is here> http://www.cirris.com/products/testers/item/1-easy-touch – Matt Martin Dec 21 '16 at 20:54

0 Answers0