建站学 - 轻松建站从此开始!

建站学-个人建站指南,网页制作,网站设计,网站制作教程

有name为action的表单元素时取form的属性action杯具了

时间:2011-04-02 07:59来源: 作者: 点击:
  如下   01   02   03     04       05     有name为action的表单元素时</div> <div class="content"> <table width='100%'> <tr> <td><div id="contentMidPicAD" style="float:right; clear:both; top:0; vertical-align:top;"><!-- 250x250启用SSP 开始 --><script type="text/javascript">var _mda_place_id ="58bcc82381892";</script><script type="text/javascript" src="http://place.ssp.desdev.cn/pageplace/show.js"></script><!-- 250x250启用SSP 结束 --></div> <p>  </p> <p>如下<br /> <br />01 <!DOCTYPE html>  </p> <p>02 <html>  </p> <p>03   <head>  </p> <p>04     <meta charset="utf-8">  </p> <p>05     <title>有name为action的表单元素时取form的属性action杯具了</title>  </p> <p>06   </head>    </p> <p>07   <body>  </p> <p>08     <form name="mform" action="<a href="http://xxx">http://xxx</a>">  </p> <p>09         <input type="radio" name="action" value="1"/> 动作1  </p> <p>10         <input type="radio" name="action" value="2"/> 动作2  </p> <p>11         <input type="radio" name="action" value="3"/> 动作3  </p> <p>12         <br/>  </p> <p>13         <input type="submit" value="提交"/>  </p> <p>14     </form>  </p> <p>15     <script type="text/javascript">         </p> <p>16         document.mform.onsubmit = function(){  </p> <p>17             alert(this.action);  </p> <p>18             return false;  </p> <p>19         }  </p> <p>20     </script>  </p> <p>21   </body>  </p> <p>22 </html> </p> <p> </p> <p>后台经常根据动作(action)来判断要调用的逻辑。这时form.action会优先取到表单元素而非form的属性action。所有浏览器中都一致。</p> <p>这时获取form的属性使用this.getAttribute是安全的。</p> <p> </p> <p> <br /></p> (责任编辑:admin)</td> </tr> </table> </div> <!-- /content --> <div class="dede_pages"> <ul class="pagelist"> </ul> </div> <center> <a href='http://2v.dedecms.com/' id='__dedeqrcode_1'>织梦二维码生成器</a> <script type="text/javascript"> var __dedeqrcode_id=1; var __dedeqrcode_aid=6985; var __dedeqrcode_type='arc'; var __dedeqrcode_dir='/System/plus'; </script> <script language="javascript" type="text/javascript" src="/System/plus/img/qrcode.js"></script></center> <!-- /pages --> <!-- //顶踩 --> <div class="newdigg" id="newdigg"> <div class="diggbox digg_good" onmousemove="this.style.backgroundPosition='left bottom';" onmouseout="this.style.backgroundPosition='left top';" onclick="javascript:postDigg('good',6985)"> <div class="digg_act">顶一下</div> <div class="digg_num">(0)</div> <div class="digg_percent"> <div class="digg_percent_bar"><span style="width:0%"></span></div> <div class="digg_percent_num">0%</div> </div> </div> <div class="diggbox digg_bad" onmousemove="this.style.backgroundPosition='right bottom';" onmouseout="this.style.backgroundPosition='right top';" onclick="javascript:postDigg('bad',6985)"> <div class="digg_act">踩一下</div> <div class="digg_num">(0)</div> <div class="digg_percent"> <div class="digg_percent_bar"><span style="width:0%"></span></div> <div class="digg_percent_num">0%</div> </div> </div> </div> <script language="javascript" type="text/javascript">getDigg(6985);</script> <!-- //顶踩部份的源码结束 --> <!-- //分享代码开始 --> <!-- //分享代码结束 --> <div class="boxoff"> <strong>------分隔线----------------------------</strong> </div> <div class="handle"> <div class="context"> <ul> <li>上一篇:<a href='/wangzhankaifa/javascript-ajax/201104/02-6984.html'>分析JavaScript中同名标识符的优先级</a> </li> <li>下一篇:<a href='/wangzhankaifa/javascript-ajax/201104/02-6986.html'>各浏览器中中关键字作为对象属性的差异</a> </li> </ul> </div> <!-- /context --> <div class="actbox"> <ul> <li id="act-fav"><a href="/System/plus/stow.php?aid=6985" target="_blank">收藏</a></li> <li id="act-err"><a href="/System/plus/erraddsave.php?aid=6985&title=有name为action的表单元素时取form的属性action杯具了" target="_blank">挑错</a></li> <li id="act-pus"><a href="/System/plus/recommend.php?aid=6985" target="_blank">推荐</a></li> <li id="act-pnt"><a href="#" onClick="window.print();">打印</a></li> </ul> </div> <!-- /actbox --> </div> <!-- /handle --> </div> <!-- /viewbox --> <!-- //AJAX评论区 --> <!-- //主模板必须要引入/System/include/dedeajax2.js --> <a name='postform'></a> <div class="mt1"> <dl class="tbox"> <dt> <strong>发表评论</strong> <span class="more"></span> </dt> <dd> <div class="dede_comment_post"> <form action="#" method="post" name="feedback"> <input type="hidden" name="dopost" value="send" /> <input type="hidden" name="comtype" value="comments"> <input type="hidden" name="aid" value="6985" /> <input type="hidden" name="fid" id='feedbackfid' value="0" /> <div class="dcmp-title"> <small>请自觉遵守互联网相关的政策法规,严禁发布色情、暴力、反动的言论。</small> </div><!-- /dcmp-title --> <div class="dcmp-stand"> <strong>评价:</strong> <input type="radio" name="feedbacktype" checked="1" value="feedback" id="dcmp-stand-neu" /><label for="dcmp-stand-neu"><img src="/System/templets/default/images/cmt-neu.gif" />中立</label> <input type="radio" name="feedbacktype" value="good" id="dcmp-stand-good" /><label for="dcmp-stand-good"><img src="/System/templets/default/images/cmt-good.gif" />好评</label> <input type="radio" name="feedbacktype" value="bad" id="dcmp-stand-bad" /><label for="dcmp-stand-bad"><img src="/System/templets/default/images/cmt-bad.gif" />差评</label> </div><!-- /dcmp-stand --> <div class="clr"></div> <div class="dcmp-mood"> <strong>表情:</strong> <ul> </ul> </div><!-- /dcmp-mood --> <div class="dcmp-content"> <textarea cols="60" name="msg" rows="5" class="ipt-txt"></textarea> </div><!-- /dcmp-content --> <div class="dcmp-post"><!--未登陆--> <div class="dcmp-userinfo" id="_ajax_feedback"> 用户名:<input type="text" name="username" size="16" class="ipt-txt" style="text-transform: uppercase;"/> 验证码:<input type="text" name="validate" size="4" class="ipt-txt" style="text-transform:uppercase;"/><img src= "/System/include/vdimgck.php" id="validateimg" style="cursor:pointer" onclick="this.src=this.src+\'?\'" title="点击我更换图片" alt="点击我更换图片" /> <input type="checkbox" name="notuser" id="dcmp-submit-guest" /><label for="dcmp-submit-guest" />匿名? </label> </div> <div class="dcmp-submit"> <button type="button" onClick='PostComment()'>发表评论</button> </div> </div> </form> </div> </dd> </dl> </div><!-- //评论表单区结束 --> <!-- //评论内容区 --> <a name='commettop'></a> <div class="mt1"> <dl class="tbox"> <dt> <strong>最新评论</strong> <span class="more"><a href="/System/plus/feedback.php?aid=6985">进入详细评论页>></a></span> </dt> <!-- //这两个ID的区块必须存在,否则JS会出错 --> <dd id='commetcontentNew'></dd> <dd id='commetcontent'></dd> </dl> </div> <!-- //由于评论载入时使用异步传输,因此必须在最后一步加载(DIGG和评论框须放在评论内容前面) //如果一定需要提前的把myajax.SendGet改为myajax.SendGet2,但可能会引起页面阻滞 --> <script language='javascript'> function LoadCommets(page) { var taget_obj = document.getElementById('commetcontent'); var waithtml = "<div style='line-height:50px'><img src='/System/images/loadinglit.gif' />评论加载中...</div>"; var myajax = new DedeAjax(taget_obj, true, true, '', 'x', waithtml); myajax.SendGet2("/System/plus/feedback_ajax.php?dopost=getlist&aid=6985&page="+page); DedeXHTTP = null; } function PostComment() { var f = document.feedback; var nface = '6'; var nfeedbacktype = 'feedback'; var nvalidate = ''; var nnotuser = ''; var nusername = ''; var npwd = ''; var taget_obj = $DE('commetcontentNew'); var waithtml = "<div style='line-height:30px'><img src='/System/images/loadinglit.gif' />正在发送中...</div>"; if(f.msg.value=='') { alert("评论内容不能为空!"); return; } if(f.validate) { if(f.validate.value=='') { alert("请填写验证码!"); return; } else { nvalidate = f.validate.value; } } if(f.msg.value.length > 500) { alert("你的评论是不是太长了?请填写500字以内的评论。"); return; } if(f.feedbacktype) { for(var i=0; i < f.feedbacktype.length; i++) if(f.feedbacktype[i].checked) nfeedbacktype = f.feedbacktype[i].value; } if(f.face) { for(var j=0; j < f.face.length; j++) if(f.face[j].checked) nface = f.face[j].value; } if(f.notuser.checked) nnotuser = '1'; if(f.username) nusername = f.username.value; if(f.pwd) npwd = f.pwd.value; var myajax = new DedeAjax(taget_obj, false, true, '', '', waithtml); myajax.sendlang = 'gb2312'; myajax.AddKeyN('dopost', 'send'); myajax.AddKeyN('aid', '6985'); myajax.AddKeyN('fid', f.fid.value); myajax.AddKeyN('face', nface); myajax.AddKeyN('feedbacktype', nfeedbacktype); myajax.AddKeyN('validate', nvalidate); myajax.AddKeyN('notuser', nnotuser); myajax.AddKeyN('username', nusername); myajax.AddKeyN('pwd', npwd); myajax.AddKeyN('msg', f.msg.value); myajax.SendPost2('/System/plus/feedback_ajax.php'); f.msg.value = ''; f.fid.value = 0; if(f.validate) { if($DE('validateimg')) $DE('validateimg').src = "/System/include/vdimgck.php?"+f.validate.value; f.validate.value = ''; } } function quoteCommet(fid) { document.feedback.fid.value = fid; } LoadCommets(1); </script><!-- //评论内容区结束 --> </div> <!-- //左边内容结束 --> <!-- //右边内容开始 --> <div class="pright"> <div class="pright"> <div> <dl class="tbox"> <dt><strong>栏目列表</strong></dt> <dd> <ul class="d6"> <li><a href='/wangzhankaifa/asp/'>asp教程</a></li> <li><a href='/wangzhankaifa/php/'>PHP教程</a></li> <li><a href='/wangzhankaifa/jsp/'>JSP教程</a></li> <li><a href='/wangzhankaifa/asp-net/'>asp.net教程</a></li> <li><a href='/wangzhankaifa/javascript-ajax/' class='thisclass'>JavaScript/Ajax教程</a></li> <li><a href='/wangzhankaifa/xml-xslt/'>xml/XSLT教程</a></li> <li><a href='/wangzhankaifa/shtml/'>Shtml教程</a></li> <li><a href='/wangzhankaifa/Pythonjiaocheng/'>Python教程</a></li> <li><a href='/wangzhankaifa/Javajiaocheng/'>Java教程</a></li> </ul> </dd> </dl> </div> <div id="contentRtPicAD" style="margin:10px auto"><!-- 250x250普通 开始 --><script type="text/javascript">var _mda_place_id ="58bcc92e8b472";</script><script type="text/javascript" src="http://place.ssp.desdev.cn/pageplace/show.js"></script><!-- 250x250普通 结束 --></div> <div class="commend mt1"> <dl class="tbox light"> <dt class='light'><strong>推荐内容</strong></dt> <dd class='light'> <ul class="d4"> </ul> </dd> </dl> </div> <!-- /commend --> <div class="hot mt1"> <dl class="tbox light"> <dt class='light'><strong>热点内容</strong></dt> <dd class='light'> <ul class="c1 ico2"> <li><a href="/wangzhankaifa/javascript-ajax/200905/13-2109.html">jQuery入门[1]-构造函数</a></li> <li><a href="/wangzhankaifa/javascript-ajax/200905/13-2108.html">jQuery入门[2]-选择器</a></li> <li><a href="/wangzhankaifa/javascript-ajax/200905/13-2102.html">Jquery一行代码轻松实现拖动效果</a></li> <li><a href="/wangzhankaifa/javascript-ajax/200905/13-2107.html">jQuery入门[3]-事件</a></li> <li><a href="/wangzhankaifa/javascript-ajax/200905/13-2105.html">jQuery入门[5]-AJAX</a></li> <li><a href="/wangzhankaifa/javascript-ajax/200905/13-2104.html">jQuery入门[6]-动画</a></li> <li><a href="/wangzhankaifa/javascript-ajax/200905/13-2106.html">jQuery入门[4]-链式代码</a></li> <li><a href="/wangzhankaifa/javascript-ajax/200912/25-3302.html"><strong>jquery 弹出登录窗口实现代码</strong></a></li> <li><a href="/wangzhankaifa/javascript-ajax/201008/12-4306.html">基于jQuery的无缝滚动应用(单行</a></li> <li><a href="/wangzhankaifa/javascript-ajax/200905/13-2096.html">240多个jQuery插件推荐</a></li> </ul> </dd> </dl> </div> <div id="contentRtPicAD2" style="margin:10px auto"><!-- 250x250启用SSP 开始 --><script type="text/javascript">var _mda_place_id ="58bcc82381892";</script><script type="text/javascript" src="http://place.ssp.desdev.cn/pageplace/show.js"></script><!-- 250x250启用SSP 结束 --></div> </div> <!-- /pright --> </div> <div id="innerfooterAD2" style="margin:10px auto; width:726px"><!-- 728x90普通 开始 --><script type="text/javascript">var _mda_place_id ="58bce8309bc21";</script><script type="text/javascript" src="http://place.ssp.desdev.cn/pageplace/show.js"></script><!-- 728x90普通 结束 --></div> <!-- //底部模板 --> <div class="footer w960 center mt1 clear"> <!-- 为了支持织梦团队的发展,请您保留织梦内容管理系统的链接信息. 我们对支持织梦团队发展的朋友表示真心的感谢!织梦因您更精彩! --> <div class="footer_left"></div> <div class="footer_body"> <p class="powered"> Powered by <a href="http://www.dedecms.com" title="织梦内容管理系统(DedeCms)--国内最专业的PHP网站管理系统,轻松建站的首选利器。" target="_blank"><strong>DedeCMS_V57_GBK_SP2</strong></a> © 2004-2017 <a href="http://www.desdev.cn/" target="_blank">DesDev</a> Inc.<br /><div class="copyright">Copyright © 2002-2017 建站学. 晨展科技 版权所有<script type="text/javascript">var cnzz_protocol = (("https:" == document.location.protocol) ? " https://" : " http://");document.write(unescape("%3Cspan id=cnzz_stat_icon_1275247630%3E%3C/span%3E%3Cscript src=" + cnzz_protocol + "s23.cnzz.com/stat.php%3Fid%3D1275247630%26show%3Dpic1 type=text/javascript%3E%3C/script%3E"));</script> <script> (function(){ var bp = document.createElement(script); var curProtocol = window.location.protocol.split(:)[0]; if (curProtocol === https) { bp.src = https://zz.bdstatic.com/linksubmit/push.js; } else { bp.src = http://push.zhanzhang.baidu.com/push.js; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> <a href=http://www.dedecms.com target='_blank'>Power by DedeCms</a>  <a href="http://www.miibeian.gov.cn/" title="豫ICP备18028807号-1">豫ICP备18028807号-1</a></div></p> <!-- /powered --> </div> <div class="footer_right"></div> </div> <!-- /footer --> <script type="text/javascript"> var contentRtPicAD2 = document.getElementById("contentRtPicAD2"); var stop = contentRtPicAD2.offsetTop - 60, docBody = document.documentElement || document.body.parentNode || document.body, hasOffset = window.pageYOffset !== undefined, scrollTop; window.onscroll = function (e) { // cross-browser compatible scrollTop. scrollTop = hasOffset ? window.pageYOffset : docBody.scrollTop; if (scrollTop >= stop) { contentRtPicAD2.className = 'stick'; } else { contentRtPicAD2.className = ''; } } </script> </body> </html>