I show in iFrame my contact form (for leads). What I need to do is to save the parent url, then to insert this url to my hidden field before the form is submitted (or on the page load). I need to know from what url the form was submitted.
I have code that works only is chrome console. but when I put this code in the parent html the code is there but not working
jQuery(".gfiframe").contents().find("#gform_submit_button_1").click(function(){
jQuery(".gfiframe").contents().find("#input_1_2").val('test');
});
To get the parent url I use
var $location = location.host;
location.host
is relative to the iframe. Instead, use document.referrer
jsFiddle Example
When the iframe's HTTP headers are sent, the parent to the iframe is sent as the referrer, therefore using document.referrer
will result in the iframe's parent URL
Update: Within your iframe, not externally, use jQuery to add the parent url to the form being submitted
$('input.parent_url').val(document.referrer);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.