【发布时间】:2017-08-29 20:21:12
【问题描述】:
我正在动态生成 iframe 并为其添加标题,但我将操作方法名称作为标题而不是给定的标题。我的代码是:
("#modalBody").empty().append('<iframe title="This is the title" id="iframeID"></iframe>');
$("#iframeID").attr("src", "../Employee/GetEmployeeDetails?empID=" + empID);
$('#empModal').modal('show');
标题为:GetEmployeeDetails 而不是 'This is the title'。
任何帮助将不胜感激。谢谢。
编辑: 我发现了一个类似的问题,但这里 iframe 是动态生成的,而在该问题中 iframe 不是动态生成的。
编辑 -2 这也给出了相同的结果:
("#modalBody").empty().append('<iframe title="This is the title" id="iframeID"></iframe>');
$("#modalBody iframe").contentDocument.title = 'My New title!';
$("#iframeID").attr("src", "../Employee/GetEmployeeDetails?empID=" + empID); $('#empModal').modal('show');
【问题讨论】:
-
@Xiaoy312 是的,我在发布问题之前已经看到了那个问题,这个问题有点不同,这里我动态生成 iframe。我试过但无法解决问题。 :)
-
对不起,为什么是 iframe?
标签: c# jquery asp.net-mvc-4 iframe