日期:2014-05-16 浏览次数:20341 次
function nodeClick(el){ var nodes = document.getElementById("mytree")[0].getElementsByTagName("a"); for (var node in nodes) { if(node.id==el.id) { var url = node.title; if(url.indexOf("aspx")>0) { document.getElementById("myframe").src = url; } } } }
------解决方案--------------------
经过消毒验证:
<div id="mytree"> <a href="javascript:void(0)" title="123.aspx">a</a> <a href="javascript:void(0)" title="23423.asp">b</a> <a href="javascript:void(0)" title="fds.html">c</a> </div> <iframe id="myframe" src=""></iframe> <script language="javascript"> var nodes = document.getElementById("mytree").getElementsByTagName("a"); for(var node in nodes){ nodes[node].onclick=(function(i){ return function(){ var title=nodes[i].title; if(title.indexOf("aspx")>0){ document.getElementById("myframe").src = title; } } })(node); } </script>
------解决方案--------------------
(function(fun){
fun(document).ready(function(){
});
})(jQuery);
fun为你要换掉的符号