Javascript 将现有变量添加到iFrame URL
这可能是非常基本的,但我们将非常感谢您的帮助 我有以下脚本,可以添加到自定义构建的web应用程序中,并在其中嵌入iframe中的另一个页面Javascript 将现有变量添加到iFrame URL,javascript,jquery,iframe,Javascript,Jquery,Iframe,这可能是非常基本的,但我们将非常感谢您的帮助 我有以下脚本,可以添加到自定义构建的web应用程序中,并在其中嵌入iframe中的另一个页面 $(function() { $('#customframe').after('<iframe src="https://www.myurl.com" style="width:100%;height:200px"></iframe>'); }); $(函数(){ $('#custom
$(function() {
$('#customframe').after('<iframe src="https://www.myurl.com" style="width:100%;height:200px"></iframe>');
});
$(函数(){
$('#customframe')。在('')之后;
});
我需要在iframe中包含一个查询参数,如下所示
$(function() {
$('#customframe').after('<iframe src="https://www.myurl.com/page.html?id=ThisRecordId" style="width:100%;height:200px"></iframe>');
});
$(函数(){
$('#customframe')。在('')之后;
});
ThisRecordId
变量已在DOM中可用。
如果我转到浏览器控制台,只需键入ThisRecordId
,它就会显示iFrame所需的值
我只是在努力让它工作
提前感谢。对字符串文字使用字符串插值, 在
${ThisRecordId}
模板中使用反勾号而不是引号并将变量括起来
更多关于模板文本的信息。
例如:
让ThisRecordId='myidnumber'
$(函数(){
$('#customframe')。在(``)之后;
});
非常感谢您的帮助John
let ThisRecordId = 'myidnumber'
$(function() {
$('#customframe').after(`<iframe src="https://www.myurl.com/page.html?id=${ThisRecordId}" style="width:100%;height:200px"></iframe>`);
});