有关iframe中子页面控制父页面里ready中的事件的问题
标题基本不能表达我想表达的确切意思,嘿嘿 把代码贴出来,
有达人请指点一下
a.html,b.html,jquery.js在同一个文件夹
注意有用到jquery,代码这里就不提供了
a.html代码如下
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><script type="text/javascript" src="jquery.js"></script><script type="text/javascript">$(document).ready(function(){ $(".ctt").click(function(e1){ $("#s3").val($(this).attr("gid")); });});</script><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>无标题文档</title></head><body><p> <label> <input class="ctt" type="submit" name="s1" id="s1" value="1111111111" gid="gid1111111111" /> <input class="ctt" type="submit" name="s4" id="s4" value="4444444444" gid="gid44444444444" /> </label></p><p> <label> <input name="s3" type="text" id="s3" value="opopopopophhh" /> </label></p><iframe src="b.html"></iframe></body></html>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>无标题文档</title></head><script type="text/javascript" src="jquery.js"></script><script type="text/javascript">$(document).ready(function(){ $("#s2").click(function(e1){ $(window.parent.document).find("#s4").attr("gid","gid2222222"); alert($(window.parent.document).find("#s4").attr("gid")); $(window.parent.document).find("#s4").click(); });});</script><body><label> <input type="submit" name="s2" id="s2" value="调用a页面中s1按钮的click动作" /></label></body></html>