在iframe中传递网址参数 [英] Passing URL parameter in iframe issue

查看:211
本文介绍了在iframe中传递网址参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

ser转到 http://yoursite.com/your-typeform-page?代码= 1 (使用浏览器),则该页面需要添加带有网址的IFRAME,网址为data-url = https://yoursite.typeform.com/to/U5aOQR?code=1

ser goes to http://yoursite.com/your-typeform-page?code=1 using a browser, that page needs to add a IFRAME with url as data-url=https://yoursite.typeform.com/to/U5aOQR?code=1

我想将url参数作为输入传递给

I want to pass url parameter as input to iFrame.

<script>
 queryString = window.location.search;
var urlParams  = new URLSearchParams(queryString);
var code = urlParams.get('code')

 </script>

  <div class="typeform-widget" data-url="https://yoursite.typeform.com/to/U5aOQR?code"+ code 
 style="width: 100%; height: 500px;"></div>
<script> (function() { var qs,js,q,s,d=document,gi=d.getElementById, ce=d.createElement, gt=d.getElementsByTagName, id="typef_orm", b="https://embed.typeform.com/"; if(!gi.call(d,id)) { js=ce.call(d,"script"); js.id=id; js.src=b+"embed.js"; q=gt.call(d,"script")[0]; q.parentNode.insertBefore(js,q) } })() </script>

 </div>

基本上我想从第4行传递代码值,以在第9行作为字符串输入。

Basically I want to pass value of code from line 4 to input as string in line 9.

谢谢您的时间和考虑。

推荐答案

我认为您的问题是这个问题

您可以看到工作示例我在Glitch上所做的

You can see a working example I made on Glitch

您可以编辑此处

复制步骤:


  1. 在HTML中包含Typeform Embed SDK

  2. 从URL提取参数

  1. Include Typeform Embed SDK in your HTML
  2. Extract parameters from URL

let params = new URLSearchParams(location.search);

重构表单URL

url += "?utm_source=" + params.get('utm_source');


  • 在目标 div

    window.typeformEmbed.makeWidget(
      embedElement,
      url, 
      {
        hideHeaders: true,
        hideFooter: true,
      }
    );```
    


  • 希望有帮助:)

    这篇关于在iframe中传递网址参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆