注:函数名是动态生成的,真实的函数如下
function qm_enableTab_6404(obj, scale, label)
{
for (i = 1; i <= 9; i++)
{
document.getElementById('qm_ch_tab' + i + '_6404').className = (i == obj) ? 'qmmt_tabactive' : 'qmmt_tab'; document.getElementById('qm_ch_tab' + i + '_6404').style.cursor = (i == obj) ? 'default' : (qm_isIE_6404()) ? 'hand': 'pointer'; document.getElementById('qm_ch_tab' + i + '_6404').style.borderTopWidth = (i == obj) ? '0px' : '1px';
}
var chtype = document.charttypes.chtype[0].value;
for (var i = 0; i < document.charttypes.chtype.length; i++)
{
if (document.charttypes.chtype[i].checked)
{
chtype = document.charttypes.chtype[i].value;
}
}
if (chtype != 'Java')
{
document.getElementById('dgraph_6404').src = 'http://app.quotemedia.com/quotetools/getChart?webmasterId=93383&symbol=AAPL&chscale='
+ scale + '&chtype=' + chtype +
'&chwid=812&chhig=350&chfill=eebb2962&chfill2=bb2962&chln=333333&chpccol=b54164&chfnts=8&chfrmon=false&chton=false&chpcon=true&chfnt=arial.ttf';
}
document.getElementById('qm_label').innerHTML = label;
}
需要修改其中的charttypes为form[0]
function qm_enableTab_6404(obj, scale, label)
{
for (i = 1; i <= 9; i++)
{
document.getElementById('qm_ch_tab' + i + '_6404').className = (i == obj) ? 'qmmt_tabactive' : 'qmmt_tab'; document.getElementById('qm_ch_tab' + i + '_6404').style.cursor = (i == obj) ? 'default' : (qm_isIE_6404()) ? 'hand': 'pointer'; document.getElementById('qm_ch_tab' + i + '_6404').style.borderTopWidth = (i == obj) ? '0px' : '1px';
}
var chtype = document.charttypes.chtype[0].value;
for (var i = 0; i < document.charttypes.chtype.length; i++)
{
if (document.charttypes.chtype[i].checked)
{
chtype = document.charttypes.chtype[i].value;
}
}
if (chtype != 'Java')
{
document.getElementById('dgraph_6404').src = 'http://app.quotemedia.com/quotetools/getChart?webmasterId=93383&symbol=AAPL&chscale='
+ scale + '&chtype=' + chtype +
'&chwid=812&chhig=350&chfill=eebb2962&chfill2=bb2962&chln=333333&chpccol=b54164&chfnts=8&chfrmon=false&chton=false&chpcon=true&chfnt=arial.ttf';
}
document.getElementById('qm_label').innerHTML = label;
}
需要修改其中的charttypes为form[0]
{ var myform = eval("document."+tform);
for (i = 1; i <= 9; i++)
{
document.getElementById('qm_ch_tab' + i + '_6404').className = (i == obj) ? 'qmmt_tabactive' : 'qmmt_tab'; document.getElementById('qm_ch_tab' + i + '_6404').style.cursor = (i == obj) ? 'default' : (qm_isIE_6404()) ? 'hand': 'pointer'; document.getElementById('qm_ch_tab' + i + '_6404').style.borderTopWidth = (i == obj) ? '0px' : '1px';
}
var chtype = myform.chtype[0].value;
for (var i = 0; i < myform.chtype.length; i++)
{
if (myform.chtype[i].checked)
{
chtype = myform.chtype[i].value;
}
}
if (chtype != 'Java')
{
document.getElementById('dgraph_6404').src = 'http://app.quotemedia.com/quotetools/getChart?webmasterId=93383&symbol=AAPL&chscale='
+ scale + '&chtype=' + chtype +
'&chwid=812&chhig=350&chfill=eebb2962&chfill2=bb2962&chln=333333&chpccol=b54164&chfnts=8&chfrmon=false&chton=false&chpcon=true&chfnt=arial.ttf';
}
document.getElementById('qm_label').innerHTML = label;
}
参考一下.
呵呵,你1楼的说法都有点看不懂,不过二楼这个用上面的倒是可以实现,你试试行不行,就是要多加一个fomr名字的参数
<form name=f1 id=f1>
<form name=f2 id=f1>
<script language=javascript>
function btnOnclick(){
alert(1);
document.f2.submit();
}
</script>
<input type=button value="testing" onclick="btnOnclick()">
</form>
</form>点击testing按钮无效报错
<from name=f1 id=f1>
<div id="qmBasicChart">
<link rel="stylesheet" href="http://app.quotemedia.com/css/tools.css" />
<script type="text/javascript" src="http://test.kkkk.com/quotetools/charts.go?k=1"></script>
<div style="text-align: right; width: 812px; padding: 12px 0px 0px 0px;">
<a href="Charts.aspx?showAdvancedCharts=1" class="qmmt">Interactive and Comparative Charts</a>
</div>
</div>
<form>
<body>
<form id=f1 name=f1>
<form id="f2" name="f2">
<script language=javascript>
function btnOnclick(){
alert(1);
document.getElementById("f2").submit();
}
</script>
<input type=button value="testing" onclick="btnOnclick()">
</form>
</form>
</body>
form不要嵌套而用其他办法解决.
<form name="aspform">
<META HTTP-EQUIV="imagetoolbar" CONTENT="no"><script type="text/javascript">
function qm_isIE_6404()
{
var ua = navigator.userAgent.toLowerCase();
var isIE = ( (ua.indexOf("msie") != -1) && (ua.indexOf("opera") == -1) && (ua.indexOf("webtv") == -1) );
return (isIE);
} function qm_enableTab_6404(obj, scale, label)
{
for (i = 1; i <= 9; i++)
{
document.getElementById('qm_ch_tab' + i + '_6404').className = (i == obj) ? 'qmmt_tabactive' : 'qmmt_tab'; document.getElementById('qm_ch_tab' + i + '_6404').style.cursor = (i == obj) ? 'default' : (qm_isIE_6404()) ? 'hand': 'pointer'; document.getElementById('qm_ch_tab' + i + '_6404').style.borderTopWidth = (i == obj) ? '0px' : '1px';
}
var chtype = document.charttypes.chtype[0].value;
for (var i = 0; i < document.charttypes.chtype.length; i++)
{
if (document.charttypes.chtype[i].checked)
{
chtype = document.charttypes.chtype[i].value;
}
}
if (chtype != 'Java')
{
document.getElementById('dgraph_6404').src = 'http://app.quotemedia.com/quotetools/getChart?webmasterId=93383&symbol=AAPL&chscale='
+ scale + '&chtype=' + chtype +
'&chwid=812&chhig=350&chfill=eebb2962&chfill2=bb2962&chln=333333&chpccol=b54164&chfnts=8&chfrmon=false&chton=false&chpcon=true&chfnt=arial.ttf';
}
document.getElementById('qm_label').innerHTML = label;
} function qm_enableJava_6404()
{
if (document.getElementById('qm_label').innerHTML.substring(0, 4) != 'Java')
{
document.location.href =
'http://app.quotemedia.com/quotetools/clientForward?targetURL=http%3A%2F%2Fdev.zecco.com%2Fquotes%2Fbeta%2Fcharts.aspx%3FSymbol%3DAAPL&targetsym=&targettype=null&targetex=&qmpage=true&action=showCharts&symbol=AAPL&chtype=Java';
}
} function qm_enableSrc_6404(chtype)
{
if (document.getElementById('qm_label').innerHTML.substring(0, 4) == 'Java')
{
document.location.href = 'http://app.quotemedia.com/quotetools/clientForward?targetURL=http%3A%2F%2Fdev.zecco.com%2Fquotes%2Fbeta%2Fcharts.aspx%3FSymbol%3DAAPL&targetsym=&targettype=null&targetex=&qmpage=true&action=showCharts&symbol=AAPL&chtype=' + chtype;
} else
{
var oldSrc = document.getElementById('dgraph_6404').src;
var chIndex = oldSrc.indexOf("chtype=") + 7;
var part2 = oldSrc.substring(chIndex, oldSrc.length);
var newSrc = oldSrc.substring(0, chIndex) + chtype + part2.substring(part2.indexOf("&"), part2.length);
document.getElementById('dgraph_6404').src = newSrc;
}
} function openHelp_6404()
{
var w = 520;
var h = 520;
var winl = (screen.width - w) / 2;
var wint = (screen.height - h) / 2;
var winprops = 'height=' + h + ',width=' + w + ',top=' + wint + ',left=' + winl + ',toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1'; win =
window.open("http://app.quotemedia.com/quotetools/javaChartHelp.go", "JavaChartHelp", winprops);
if (parseInt(navigator.appVersion) >= 4)
{
win.focus();
}
}</script>
<tr>
<td style="text-align: center">
<div class="qmmt_header_bar" style="padding-top: 1px; padding-bottom: 1px; border-bottom-width: 1px;">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<td><span class="qmmt_header_text" style="padding-left: 3px">Charts for Apple Inc. (AAPL)</span></td>
<td class="qmmt_header_text" style="text-align: right; padding-right: 6px; font-weight:normal;">
<div id="qm_textChange_0833"><span class="qmmt_header_text" style="font-weight:normal;">Mar 11 6:40 AM EDT</span></div>
<script type="text/javascript">
function qm_UpdateText_0833(phase)
{
switch (phase)
{
case 1:
document.getElementById('qm_textChange_0833').innerHTML = '<span class="qmmt_header_text" style="font-weight:normal;">delayed 20 minutes</span>';
setTimeout("qm_UpdateText_0833(2)", 5000);
break;
case 2:
document.getElementById('qm_textChange_0833').innerHTML = '<span class="qmmt_header_text" style="font-weight:normal;">Mar 11 6:40 AM EDT</span>';
setTimeout("qm_UpdateText_0833(3)", 5000);
break;
case 3:
document.getElementById('qm_textChange_0833').innerHTML = '<a href="http://www.quotemedia.com/" target="_top" style="text-decoration:none;"><span class="qmmt_header_text" style="font-weight:normal;">© quotemedia.com</span></a>';
setTimeout("qm_UpdateText_0833(1)", 5000);
break;
}
}
qm_UpdateText_0833(2);
</script>
</td>
</tr>
</table>
</div>
</td>
</tr>
<tr> <!-- main content -->
<td>
<div class="qmmt_cycle" style="padding-top: 1px; padding-bottom: 5px; border-bottom-width: 1px;">
<table cellpadding="0" cellspacing="0" border="0" width="100%">
<tr>
<form name="charttypes">
<td class="qmmt_text" valign="bottom" width="20%" id="qm_label" style="padding-left: 6px; font-weight: bold;" align="left">Intraday</td>
<td width="80%" style='padding-right: 6px;' align="right">
<table cellpadding="0" cellspacing="0" align="right">
<tr>
<td class="qmmt_text" style="font-weight: normal;" valign="bottom" align="right">
<INPUT type="radio" class="qm_radio_input" name="chtype" value="FinancialAreaChart"
onClick="qm_enableSrc_6404('FinancialAreaChart')">
</td>
<td class="qmmt_header_text" valign="bottom" style="font-weight: normal;" align="left">Area </td>
<td class="qmmt_text" style="font-weight: normal;" valign="bottom" align="right">
<INPUT type="radio" class="qm_radio_input" name="chtype" value="FinancialLine" checked="true"
onClick="qm_enableSrc_6404('FinancialLine')">
</td>
<td class="qmmt_header_text" valign="bottom" style="font-weight: normal;" align="left">Line </td>
<td class="qmmt_text" style="font-weight: normal;" valign="bottom" align="right">
<INPUT type="radio" class="qm_radio_input" name="chtype" value="FinancialBar" onClick="qm_enableSrc_6404('FinancialBar')">
</td>
<td class="qmmt_header_text" valign="bottom" style="font-weight: normal;" align="left">Bar </td>
<td class="qmmt_text" style="font-weight: normal;" valign="bottom" align="right">
<INPUT type="radio" class="qm_radio_input" name="chtype" value="FinancialCandleStick"
onClick="qm_enableSrc_6404('FinancialCandleStick')">
</td>
<td class="qmmt_header_text" valign="bottom" style="font-weight: normal;" align="left">Candlestick</td>
</tr>
</table>
</td>
</form>
</tr>
</table>
</div>
</td>
</tr>
<tr>
<td id="chart_cell_6404" align="center">
<img id="dgraph_6404" width="812" height="350"
src="http://app.quotemedia.com/quotetools/getChart?webmasterId=93383&symbol=AAPL&chscale=1d&chtype=FinancialLine&chwid=812&chhig=350&chfill=eebb2962&chfill2=bb2962&chln=333333&chpccol=b54164&chfnts=8&chfrmon=false&chton=false&chpcon=true&chfnt=arial.ttf" GALLERYIMG="no">
<table cellpadding="0" cellspacing="0" border="0" width="100%" align="center">
<tr>
<td id="qm_ch_tab1_6404" class="qmmt_tabactive" onclick="qm_enableTab_6404('1', '1d', 'Intraday')"
style="cursor: default; border-left: 0px none; border-bottom: 0px none; border-right: 0px none; border-top-width: 0px; padding-top:1px; padding-bottom:1px;">Intraday</td>
<td id="qm_ch_tab2_6404" class="qmmt_tab" onclick="qm_enableTab_6404('2', '5d', '1 Week')"
style="cursor: default; border-right: 0px; border-bottom: 0px; padding-top:1px; padding-bottom:1px;">5 Dy</td>
<td id="qm_ch_tab3_6404" class="qmmt_tab" onclick="qm_enableTab_6404('3', '1m', '1 Month')"
style="cursor: default; border-right: 0px; border-bottom: 0px; padding-top:1px; padding-bottom:1px;">1 Mo</td>
<td id="qm_ch_tab4_6404" class="qmmt_tab" onclick="qm_enableTab_6404('4', '3m', '3 Month')"
style="cursor: default; border-right: 0px; border-bottom: 0px; padding-top:1px; padding-bottom:1px;">3 Mo</td>
<td id="qm_ch_tab5_6404" class="qmmt_tab" onclick="qm_enableTab_6404('5', '6m', '6 Month')"
style="cursor: default; border-right: 0px; border-bottom: 0px; padding-top:1px; padding-bottom:1px;">6 Mo</td>
<td id="qm_ch_tab6_6404" class="qmmt_tab" onclick="qm_enableTab_6404('6', '1y', '1 Year')"
style="cursor: default; border-right: 0px; border-bottom: 0px; padding-top:1px; padding-bottom:1px;">1 Yr</td>
<td id="qm_ch_tab7_6404" class="qmmt_tab" onclick="qm_enableTab_6404('7', '2y', '2 Year')"
style="cursor: default; border-right: 0px; border-bottom: 0px; padding-top:1px; padding-bottom:1px;">2 Yr</td>
<td id="qm_ch_tab8_6404" class="qmmt_tab" onclick="qm_enableTab_6404('8', '5y', '5 Year')"
style="cursor: default; border-right: 0px; border-bottom: 0px; padding-top:1px; padding-bottom:1px;"">5 Yr</td>
<td id="qm_ch_tab9_6404" class="qmmt_tab" onclick="qm_enableTab_6404('9', '10y', '10 Year')"
style="cursor: default; border-right: 0px; border-bottom: 0px; padding-top:1px; padding-bottom:1px;"">10 Yr</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</body>
<script language=javascript>
var theObj = document.getElementsByTagName("img");
var randomNum=0;
for (var i = 0;i < theObj.length ;i++ )
{
if (theObj[i].id.substring(0,6) == "dgraph")
{
randomNum = theObj[i].id.substring(7,theObj[i].id.length);
break;
}
} var basicFirstUrl = document.getElementById("dgraph_"+randomNum).src;
var basicEndUrl = "";
var arr;
//-- remove the chscale and chtype parameters
arr = basicFirstUrl.split('&chscale=');
basicFirstUrl= arr[0] + arr[1].substring(arr[1].indexOf('&')); arr = basicFirstUrl.split('&chtype=');
basicFirstUrl= arr[0] + arr[1].substring(arr[1].indexOf('&'));
//-- basicFirstUrl : http://app.quotemedia.com/quotetools/getChart?webmasterId=93383&symbol=AAPL
//-- basicEndUrl : &chwid=812&chhig=350&chfill=eebb2962&chfill2=bb2962&chln=333333&chpccol=b54164&chfnts=8&chfrmon=false&chton=false&chpcon=true&chfnt=arial.ttf
arr = basicFirstUrl.split('&symbol=');
basicFirstUrl=arr[0]+"&symbol="+arr[1].substring(0,arr[1].indexOf('&'));
basicEndUrl = arr[1].substring(arr[1].indexOf('&'),arr[1].length); document.write(" <script language=javascript>");
document.write(" function qm_enableTab_"+randomNum+"(obj, scale, label)");
document.write(" {");
document.write(" for (i = 1; i <= 9; i++)");
document.write(" { ");
document.write(" document.getElementById('qm_ch_tab'+i+'_"+randomNum+"').className=(i==obj)?'qmmt_tabactive':'qmmt_tab';");
document.write(" document.getElementById('qm_ch_tab'+i+'_"+randomNum+"').style.cursor=(i == obj)?'default':'pointer';");
document.write(" document.getElementById('qm_ch_tab'+i+'_"+randomNum+"').style.borderTopWidth=(i==obj)?'0px':'1px'; ");
document.write(" } ");
document.write(" var chtype=document.forms[0].chtype[0].value;");
document.write(" for (var i=0; i<document.forms[0].chtype.length; i++) ");
document.write(" { ");
document.write(" if (document.forms[0].chtype[i].checked)");
document.write(" { ");
document.write(" chtype = document.forms[0].chtype[i].value;");
document.write(" } ");
document.write(" } ");
document.write(" if (chtype != 'Java') ");
document.write(" { ");
document.write(" document.getElementById('dgraph_"+randomNum+"').src = '"+basicFirstUrl+"&chscale='+scale+'&chtype='+chtype+'"+basicEndUrl+"'; ");
document.write(" } ");
document.write(" document.getElementById('qm_label').innerHTML = label; ");
document.write(" } ");
document.write("<\/script>");
</script>
修改函数代码比较容易,但是貌似form嵌套现在的浏览器中还存在大量问题.
function qm_enableTab_6404(obj, scale, label)
{
for (i = 1; i <= 9; i++)
{
document.getElementById('qm_ch_tab' + i + '_6404').className = (i == obj) ? 'qmmt_tabactive' : 'qmmt_tab'; document.getElementById('qm_ch_tab' + i + '_6404').style.cursor = (i == obj) ? 'default' : (qm_isIE_6404()) ? 'hand': 'pointer'; document.getElementById('qm_ch_tab' + i + '_6404').style.borderTopWidth = (i == obj) ? '0px' : '1px';
}
var chtype = document.charttypes.chtype[0].value;
for (var i = 0; i < document.charttypes.chtype.length; i++)
{
if (document.charttypes.chtype[i].checked)
{
chtype = document.charttypes.chtype[i].value;
}
}
if (chtype != 'Java')
{
document.getElementById('dgraph_6404').src = 'http://app.quotemedia.com/quotetools/getChart?webmasterId=93383&symbol=AAPL&chscale='
+ scale + '&chtype=' + chtype +
'&chwid=812&chhig=350&chfill=eebb2962&chfill2=bb2962&chln=333333&chpccol=b54164&chfnts=8&chfrmon=false&chton=false&chpcon=true&chfnt=arial.ttf';
}
document.getElementById('qm_label').innerHTML = label;
}
调用的时候
qm_enableTab_6404(obj, scale, label,"form[0]") function qm_enableTab_6404(obj, scale, label,tform)
{ var myform = eval("document."+tform);
for (i = 1; i <= 9; i++)
{
document.getElementById('qm_ch_tab' + i + '_6404').className = (i == obj) ? 'qmmt_tabactive' : 'qmmt_tab'; document.getElementById('qm_ch_tab' + i + '_6404').style.cursor = (i == obj) ? 'default' : (qm_isIE_6404()) ? 'hand': 'pointer'; document.getElementById('qm_ch_tab' + i + '_6404').style.borderTopWidth = (i == obj) ? '0px' : '1px';
}
var chtype = myform.chtype[0].value;
for (var i = 0; i < myform.chtype.length; i++)
{
if (myform.chtype[i].checked)
{
chtype = myform.chtype[i].value;
}
}
if (chtype != 'Java')
{
document.getElementById('dgraph_6404').src = 'http://app.quotemedia.com/quotetools/getChart?webmasterId=93383&symbol=AAPL&chscale='
+ scale + '&chtype=' + chtype +
'&chwid=812&chhig=350&chfill=eebb2962&chfill2=bb2962&chln=333333&chpccol=b54164&chfnts=8&chfrmon=false&chton=false&chpcon=true&chfnt=arial.ttf';
}
document.getElementById('qm_label').innerHTML = label;
}
<script language=javascript>
/*例*/
function btnOnclick(){
//alert(1);
return true;
// document.getElementById("f2".submit();
}
eval(btnOnclick.toString().replace("true","false"));
alert(btnOnclick())
/*例*/
/*以下自己根据实际改*/
function qm_enableTab_6404(obj, scale, label)
{
for (i = 1; i <= 9; i++)
{
document.getElementById('qm_ch_tab' + i + '_6404').className = (i == obj) ? 'qmmt_tabactive' : 'qmmt_tab'; document.getElementById('qm_ch_tab' + i + '_6404').style.cursor = (i == obj) ? 'default' : (qm_isIE_6404()) ? 'hand': 'pointer'; document.getElementById('qm_ch_tab' + i + '_6404').style.borderTopWidth = (i == obj) ? '0px' : '1px';
}
var chtype = document.charttypes.chtype[0].value;
for (var i = 0; i < document.charttypes.chtype.length; i++)
{
if (document.charttypes.chtype[i].checked)
{
chtype = document.charttypes.chtype[i].value;
}
}
if (chtype != 'Java')
{
document.getElementById('dgraph_6404').src = 'http://app.quotemedia.com/quotetools/getChart?webmasterId=93383&symbol=AAPL&chscale='
+ scale + '&chtype=' + chtype +
'&chwid=812&chhig=350&chfill=eebb2962&chfill2=bb2962&chln=333333&chpccol=b54164&chfnts=8&chfrmon=false&chton=false&chpcon=true&chfnt=arial.ttf';
}
document.getElementById('qm_label').innerHTML = label;
} eval(qm_enableTab_6404.toString().replace(/charttypes/ig,"form[0]"));
alert(qm_enableTab_6404)
</script>