将变量传递给MS Forms IFRAME

时间:2019-10-10 11:16:20

标签: iframe microsoft-forms ms-forms

我有一个下面要传递变量的MSForms IFRAME:

<iframe width="640px" height= "480px" src= "https://forms.office.com/Pages/ResponsePage.aspx?id=WnOMPGahs0mNAXXXXXXLalRLguiTSkoG369UQThGNUlVRjFSWUYyQlpWOTAyVEVUQUNJNyQlQCN0PWcu&embed=true" frameborder= "0" marginwidth= "0" marginheight= "0" style= "border: none; max-width:100%; max-height:100vh" allowfullscreen webkitallowfullscreen mozallowfullscreen msallowfullscreen> </iframe>

我想将变量动态传递给IFRAME,以预填充某些MS Form字段。

有关如何实现此目标的任何提示。我的研究并不成功,但是我可以找到一种针对MS Forms Pro的方法,但找不到针对MS Forms的方法。

1 个答案:

答案 0 :(得分:0)

如果您想使用JavaScript在iframe中传递一个Veriable,请在脚本onLoad以下加载,这意味着在页面加载时应加载该值。如果需要确定,请在浏览器控制台中进行检查。

var yourVeriable = "veriableValue";
document.querySelector(".passaclasstoiframe").setAttribute("customattr", yourVeriable);

如果您有jquery,这很容易。

$(document).ready(function(){
  var yourVeriable = "veriableValue";
  $('.passaclasstoiframe').attr("customattr", yourVeriable);
  //but for this, you have to put customattr="" in your iframe.
  //<iframe width="640px" height= "480px" src= "src" customattr=""></iframe>
})

如果您使用C#asp.net进行此操作,我建议您使用javascript将Veriable放入iframe。

相关问题