请教一个js问题? 假设我有两个jsp页面:list1和list2,list1里有两个函数function1和function2;list2里有一个form表单。现在我想用一个js来控制使得function1可以跳转list2页面,function2也可以跳转到list2页面但是使form表单里的input属性为readonly,求教这个js怎么写? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 list2<script type="text/javascript"> function init(){ var a=window.location.href; if(a.indexOf("readonly=true")!=-1){ var input=document.getElementsByTagName("input"); for(var i=0;i<input.length;i++){ input[i].setAttribute('readonly',"readonly"); } } } window.onload=init;</script></head><body><form> <input type="text" > <input type="button" value="test"></form></body></html>list1<script type="text/javascript"> function ss(){ var a="Untitled-1.html"; if(arguments.length>0){ a="Untitled-1.html?readonly=true"; } window.location.href=a; }</script></head><body><input type="button" value="function1" onclick="ss()"><input type="button" value="function2" onclick="ss('x')"></body></html>这样试试 或者跳转的时候通过form表单传递个参数 然后由list1接收 如果符合则只读,否则可写 试试上面的跳转地址写错了 iframe里如何使用父页的对象? 新手提问 同一页面js函数的调用 Ext 日期比较 jquery 取出的对象怎么和getElementById的对象一样? JS错怎么改,提示missing(before function paramenters),请大家帮忙一下! 为什么js设置ENCTYPE时要用encoding 求一个js格式化成特定字符串的函数,并递减,我弄了很久没搞定,请高手帮忙 Flash的小问题 关闭窗体的问题 jquery高版本问题 插入HTML元素不成功来人解决下 new Array 逗号如何去掉???
function init(){
var a=window.location.href;
if(a.indexOf("readonly=true")!=-1){
var input=document.getElementsByTagName("input");
for(var i=0;i<input.length;i++){
input[i].setAttribute('readonly',"readonly");
}
}
}
window.onload=init;
</script>
</head><body>
<form>
<input type="text" >
<input type="button" value="test">
</form>
</body>
</html>list1<script type="text/javascript">
function ss(){
var a="Untitled-1.html";
if(arguments.length>0){
a="Untitled-1.html?readonly=true";
}
window.location.href=a;
}
</script>
</head><body>
<input type="button" value="function1" onclick="ss()">
<input type="button" value="function2" onclick="ss('x')">
</body>
</html>
这样试试
上面的跳转地址写错了