URL Parameter with Forms 2.0 in iFrame | Community
Skip to main content
Level 2
September 11, 2014
Question

URL Parameter with Forms 2.0 in iFrame

  • September 11, 2014
  • 1 reply
  • 1095 views
Hello All,
I am hoping someone can help.  I implemented a solution using the script found here: (https://community.marketo.com/MarketoResource?id=kA650000000GuKCCA0) with my older forms buf found that it does not work with Forms 2.0.  Can anyone out there help me modify my script to make it work with Forms 2.0?

Here is what I have right now:

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<!-- Keep your jQuery up to date -->
 
<script>
 
  $(function(){
    var url = (window.location != window.parent.location) ? document.referrer: document.location;
    var sourceParam = getUrlVars(url)["leadsource"];
    $("#LeadSource").val(sourceParam);
  })
    
  function getUrlVars(url) {
    var vars = [],
        hash;
    var hashes = url.slice(url.indexOf('?') + 1).split('&');
    for (var i = 0; i < hashes.length; i++) {
        hash = hashes[i].split('=');
        vars.push(hash[0]);
        vars[hash[0]] = hash[1];
    }
    return vars;
  }
 
</script>

Any suggestions are greatly apprecaited!  Thanks!
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

1 reply

Grant_Booth
Level 9
September 11, 2014
This other discussion has some insight (see Kenny's third comment):
https://community.marketo.com/MarketoDiscussionDetail?id=90650000000PrHrAAK

In that discussion, the "referrer" they are referring to is actually a URL parameter in that particular use case.