前台 js 改成:
$(function () {
$("ul.tabs").tabs("div.panes > div");
$("ul.tabs a").click( function(){ // 点击后才加载
var index = $("ul.tabs a").index( this);
var content = $("div.panes div").eq(index);
if (content.find("iframe:first").attr("src") == "") {
content.find("iframe:first").attr("src", content.find("input[type=hidden]:first").val());
}
});
$("ul.tabs a").click( function(){ // 点击后才加载
var index = $("ul.tabs a").index( this);
var content = $("div.panes div").eq(index);
if (content.find("iframe:first").attr("src") == "") {
content.find("iframe:first").attr("src", content.find("input[type=hidden]:first").val());
}
});
});
C#:
StringBuilder str_tabs =
new StringBuilder();
str_tabs.Append( " <div class='panes'> ");
for ( int i = 0; i < DS.Rows.Count; i++)
{
if (i == 0) // 第一次默认加载
{
str_tabs.Append( " <div> ");
str_tabs.Append( " <iframe name='fraChart' src='ChartForm.aspx?Type= " + ChartFormType + " &FormUrl= " + DS.Rows[i][ " FormUrl "].ToString() + " ' frameborder='0' style='width:100%;height:100%;border:1px solid #aaa ;' scrolling='auto' height='100%'></iframe> ");
str_tabs.Append( " </div> ");
continue;
}
str_tabs.Append( " <div> ");
str_tabs.Append( " <input type='hidden' value='ChartForm.aspx?Type= " + ChartFormType + " &FormUrl= " + DS.Rows[i][ " FormUrl "].ToString() + " ' /> ");
str_tabs.Append( " <iframe name='fraChart' src='' frameborder='0' style='width:100%;height:100%;border:1px solid #aaa ;' scrolling='auto' height='100%'></iframe> ");
str_tabs.Append( " </div> ");
}
str_tabs.Append( " <div class='panes'> ");
for ( int i = 0; i < DS.Rows.Count; i++)
{
if (i == 0) // 第一次默认加载
{
str_tabs.Append( " <div> ");
str_tabs.Append( " <iframe name='fraChart' src='ChartForm.aspx?Type= " + ChartFormType + " &FormUrl= " + DS.Rows[i][ " FormUrl "].ToString() + " ' frameborder='0' style='width:100%;height:100%;border:1px solid #aaa ;' scrolling='auto' height='100%'></iframe> ");
str_tabs.Append( " </div> ");
continue;
}
str_tabs.Append( " <div> ");
str_tabs.Append( " <input type='hidden' value='ChartForm.aspx?Type= " + ChartFormType + " &FormUrl= " + DS.Rows[i][ " FormUrl "].ToString() + " ' /> ");
str_tabs.Append( " <iframe name='fraChart' src='' frameborder='0' style='width:100%;height:100%;border:1px solid #aaa ;' scrolling='auto' height='100%'></iframe> ");
str_tabs.Append( " </div> ");
}
str_tabs.Append("</div>");