在iframe中传递网址参数 [英] Passing URL parameter in iframe issue
问题描述
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
您可以编辑此处。
复制步骤:
- 在HTML中包含Typeform Embed SDK
-
从URL提取参数
- Include Typeform Embed SDK in your HTML
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屋!