-1

目前我的页面: http: //www.sagu.edu/spec-home

特别是页脚形式。

我目前正在尝试访问电子邮件字段 Field121。

目前我有这个:

var trackcmp_email = wufooFormm73jde715tzew1.document.getElementById("form227").Field121.value;

但它显示错误说wufooFormm73jde715t

<div class="custom">
  <div id="wufoo-m73jde715tzew1">
    <iframe id="wufooFormm73jde715tzew1" class="wufoo-form-container" height="383" allowtransparency="true" frameborder="0" scrolling="no" style="width:100%;border:none" src="https://sagu.wufoo.com/embed/m73jde715tzew1/def/embedKey=m73jde715tzew1327047&amp;entsource=&amp;referrer=">&lt;a href="https://sagu.wufoo.com/forms/m73jde715tzew1/" title="html form"&gt;Fill out my Wufoo form!&lt;/a&gt;</iframe>
  </div>
  <script type="text/javascript">
    var m73jde715tzew1;
    (function(d, t) {
      var s = d.createElement(t),
        options = {
          'userName': 'sagu',
          'formHash': 'm73jde715tzew1',
          'autoResize': true,
          'height': '1022',
          'async': true,
          'host': 'wufoo.com',
          'header': 'show',
          'ssl': true
        };
      s.src = ('https:' == d.location.protocol ? 'https://' : 'http://') + 'www.wufoo.com/scripts/embed/form.js';
      s.onload = s.onreadystatechange = function() {
        var rs = this.readyState;
        if (rs)
          if (rs != 'complete')
            if (rs != 'loaded') return;
        try {
          m73jde715tzew1 = new WufooForm();
          m73jde715tzew1.initialize(options);
          m73jde715tzew1.display();
        } catch (e) {}
      };
      var scr = d.getElementsByTagName(t)[0],
        par = scr.parentNode;
      par.insertBefore(s, scr);
    })(document, 'script');
  </script>
  <script type="text/javascript">
    var trackcmp_email = wufooFormm73jde715tzew1.document.getElementById("form227").Field121.value;
    alert(trackcmp_email);
    var trackcmp = document.createElement("script");
    trackcmp.async = true;
    trackcmp.type = 'text/javascript';
    trackcmp.src = '//trackcmp.net/visit?actid=609412436&e=' + encodeURIComponent(trackcmp_email) + '&r=' + encodeURIComponent(document.referrer) + '&u=' + encodeURIComponent(window.location.href);
    var trackcmp_s = document.getElementsByTagName("script");
    if (trackcmp_s.length) {
      trackcmp_s[0].parentNode.appendChild(trackcmp);
    } else {
      var trackcmp_h = document.getElementsByTagName("head");
      trackcmp_h.length && trackcmp_h[0].appendChild(trackcmp);
    }
  </script>
</div>

zew1 is not defined.

这是iframe我试图访问的:

<div id="wufoo-m73jde715tzew1"><iframe id="wufooFormm73jde715tzew1" class="wufoo-form-container" height="383" allowtransparency="true" frameborder="0" scrolling="no" style="width:100%;border:none" src="https://sagu.wufoo.com/embed/m73jde715tzew1/def/embedKey=m73jde715tzew1327047&amp;entsource=&amp;referrer=">&lt;a href="https://sagu.wufoo.com/forms/m73jde715tzew1/" title="html form"&gt;Fill out my Wufoo form!&lt;/a&gt;</iframe></div>

我正在尝试将 wufoo iframe 中的电子邮件字段用于此处找到的活动活动:

<script type="text/javascript">


var trackcmp_email = wufooFormm73jde715tzew1.document.getElementById("form227").Field121.value;
alert(trackcmp_email);
var trackcmp = document.createElement("script");
trackcmp.async = true;
trackcmp.type = 'text/javascript';
trackcmp.src = '//trackcmp.net/visit?actid=609412436&e='+encodeURIComponent(trackcmp_email)+'&r='+encodeURIComponent(document.referrer)+'&u='+encodeURIComponent(window.location.href);
var trackcmp_s = document.getElementsByTagName("script");
if (trackcmp_s.length) {
    trackcmp_s[0].parentNode.appendChild(trackcmp);
} else {
    var trackcmp_h = document.getElementsByTagName("head");
    trackcmp_h.length && trackcmp_h[0].appendChild(trackcmp);
}
</script>
4

2 回答 2

1

您需要按如下方式引用 iFrame:

window.frames['myIFrame'].document.getElementById('myIFrameElemId');

所以在你的情况下:

window.frames['wufooFormm73jde715tzew1'].document.getElementById('form227')

于 2014-10-31T17:41:00.980 回答
1

请尝试下一个代码:

document.getElementById('wufooFormm73jde715tzew1').contentWindow.document.getElementById("form227")

它应该适用于嵌入式 iframe。但是,如果 iframe 中的页面是从不同的域(例如 google.com)加载的,您将无法执行此操作。这是因为浏览器的政策。

于 2014-11-03T14:15:42.193 回答