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?