【问题标题】:Grab Parameters From URL Using HTML Only [For Typeform Embedding]仅使用 HTML 从 URL 中获取参数 [用于 Typeform 嵌入]
【发布时间】:2019-03-17 01:19:54
【问题描述】:

一个简单的问题。

<html> <head> <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"> <title>Re-Imagining Business Models</title> <style type="text/css"> html{ margin: 0; height: 100%; overflow: hidden; } iframe{ position: absolute; left:0; right:0; bottom:0; top:0; border:0; } </style> </head> <body> <iframe id="typeform-full" width="100%" height="100%" frameborder="0" src="https://f03.typeform.com/to/AAAAAA?cl=xxxxx"></iframe> <script type="text/javascript" src="https://embed.typeform.com/embed.js"></script> </body> </html>

如果你能看到cl=xxxxx,我需要根据网站输入的参数来更改xxxxx。

来自示例:

www.mywebsite.com/formpage?cl=123121

iframe 将运行这个网站:https://f03.typeform.com/to/AAAAAA?cl=123121

是否可以只使用 HTML?因为我正在使用 Wordpress,除了构建器和编辑 HTML 之外,我不知道我能在其中做什么。

谢谢

【问题讨论】:

    标签: html wordpress iframe embed typeform


    【解决方案1】:

    这可以使用Typeform Embed API

    你可以看到我在 Glitch 上制作的 working example

    您可以编辑here

    重现步骤:

    1. 在您的 HTML 中包含 Typeform Embed SDK
    2. 从 URL 中提取参数

      let params = new URLSearchParams(location.search);

    3. 重构您的表单 URL

      var url = "https://YOUR_SUBDOMAIN.typeform.com/to/YOUR_TYPEFORM_ID"; url += "?utm_source=" + params.get('utm_source');

    4. 在目标div中显示表单

      const embedElement = document.querySelector('.target-dom-node'); window.typeformEmbed.makeWidget( embedElement, url, { hideHeaders: true, hideFooter: true, } );

    希望对你有帮助:)

    【讨论】:

    • 谢谢。我已经在 Django 中安装了 Typeform SDK。但是你能按照pypi.org/project/django-typeform docs的建议帮助使用模板标签来使用typeform sdk吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-01-02
    • 1970-01-01
    • 2018-12-23
    • 1970-01-01
    • 1970-01-01
    • 2018-11-19
    • 2018-09-02
    相关资源
    最近更新 更多