php 用 js 动态添加 onclick 本帖最后由 wealsh 于 2013-09-28 10:18:31 编辑 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 /* 这注释掉 content.innerHTML = str + "<a href='javascript:void(0)' onclick= 'alert(\"这里没有问题\") ' >点击查看</a>"; //这里可以弹对话框*/ content.innerHTML = str + "<a href='javascript:void(0)' onclick= 'showuser(\"不起作用\") ' >点击查看</a>"; //这里调用 showuser 函数不起作用,请问为什么?在 showuser 函数的第一行加 alert(1) 看看有没进入 没有,onclick= 'alert 就可以,改成我定义的函数都无效? 可能 你 showuser 没定义成功 showuser,或不是在window 下你直接在HTML里加 <button onclick="showuser('test')" > test </button> 试试 unction content(str){var content = parent.frames['acount'].document.getElementById('content'); content.innerHTML = str ;showuser(str); //这里是可以调用的} content 是在acount 页面 所以调用 不到 <script language="javascript">function showuser(str){ alert(str);}function content(str){ acount=parent.frames['acount'];acount.showuser=showuser;var content =acount.document.getElementById('content'); content.innerHTML = str + "<a href='javascript:void(0)' onclick= 'showuser(\"不起作用\") ' >点击查看</a>"; }</script> 可以了,谢谢,不过还有个问题,参数赋值好像不行?function content(str,Str2){ acount=parent.frames['acount'];acount.showuser=showuser;var content =acount.document.getElementById('content'); content.innerHTML = str + "<a href='javascript:void(0)' onclick= 'showuser(Str2) ' >点击查看</a>"; } function content(str,Str2){ acount=parent.frames['acount'];acount.showuser=showuser;var content =acount.document.getElementById('content'); content.innerHTML = str + "<a href='javascript:void(0)' onclick= 'showuser(\"" + Str2+ "\") ' >点击查看</a>"; } 大家用的js集成开发环境常用的是什么啊,回着送分 js直接调用js 在线急等关于ie8的现实问题 值同步问题 如何发布pdf文档? TOMCAT 5配置一连接池,测试的时候<出现?? 求一段判断日期先后的代码 模式对话框问题! 如何对层进行定位?--表格中有10行,没行有一个文本框或下拉框,如何实现当点击其中一个文本框或下拉框时将层移置文本框或下拉框正下方 js 图片旋转后,更换另一张图片src ,新的图片为什么也被旋转了?代码如下 flot 坐标轴标题显示问题 推荐个比较好用的 jquery 表格
/* 这注释掉
content.innerHTML = str + "<a href='javascript:void(0)' onclick= 'alert(\"这里没有问题\") ' >点击查看</a>"; //这里可以弹对话框*/
content.innerHTML = str + "<a href='javascript:void(0)' onclick= 'showuser(\"不起作用\") ' >点击查看</a>"; //这里调用 showuser 函数不起作用,请问为什么?在 showuser 函数的第一行加 alert(1) 看看有没进入
你直接在HTML里加 <button onclick="showuser('test')" > test </button> 试试
content.innerHTML = str ;showuser(str); //这里是可以调用的}
function showuser(str){
alert(str);
}
function content(str){
acount=parent.frames['acount'];
acount.showuser=showuser;
var content =acount.document.getElementById('content');
content.innerHTML = str + "<a href='javascript:void(0)' onclick= 'showuser(\"不起作用\") ' >点击查看</a>";
}
</script>
function content(str,Str2){
acount=parent.frames['acount'];
acount.showuser=showuser;
var content =acount.document.getElementById('content');
content.innerHTML = str + "<a href='javascript:void(0)' onclick= 'showuser(Str2) ' >点击查看</a>";
}
acount=parent.frames['acount'];
acount.showuser=showuser;
var content =acount.document.getElementById('content');
content.innerHTML = str + "<a href='javascript:void(0)' onclick= 'showuser(\"" + Str2+ "\") ' >点击查看</a>";
}