父页面
View Code
<
html
>
<
head
>
<
script
src
=”jquery.js”
type
=”text/javascript”
></
script
>
<
script
type
=”text/javascript”
>
$(document).ready(
function
(){
$(
“
#btn
“
).click(
function
(){
var
sondocument
=
$(window.frames[
0
].document)
alert(sondocument.find(
“
#smsg
“
).html());
})});
</
script
>
</
head
>
<
body
>
<
div
>
below me it is an iframe
</
div
>
<
iframe
id
=”myiframe”
src
=”son.html”
width
=”300px;”
height
=”500px;”
></
iframe
>
<
div
id
=”mm”
>
if you see me through alert from an son’s button,you win!
</
div
>
<
input
type
=”button”
id
=”btn”
value
=”click me “
/>
html
>
<
head
>
<
script
src
=”jquery.js”
type
=”text/javascript”
></
script
>
<
script
type
=”text/javascript”
>
$(document).ready(
function
(){
$(
“
#btn
“
).click(
function
(){
var
sondocument
=
$(window.frames[
0
].document)
alert(sondocument.find(
“
#smsg
“
).html());
})});
</
script
>
</
head
>
<
body
>
<
div
>
below me it is an iframe
</
div
>
<
iframe
id
=”myiframe”
src
=”son.html”
width
=”300px;”
height
=”500px;”
></
iframe
>
<
div
id
=”mm”
>
if you see me through alert from an son’s button,you win!
</
div
>
<
input
type
=”button”
id
=”btn”
value
=”click me “
/>
</
body
>
</
html
>
子页面
View Code
<
html
>
<
head
>
<
script
src
=”jquery.js”
type
=”text/javascript”
></
script
>
<
script
type
=”text/javascript”
>
$(document).ready(
function
(){
$(
“
#btn
“
).click(
function
(){
var
mm
=
$(
‘
#mm
‘
, window.parent.document)
alert(mm.html())
})});
</
script
>
</
head
>
<
body
>
<
input
type
=”button”
id
=”btn”
value
=”click me “
/>
<
div
>
click the button above to get parent element’s innerHTML
</
div
>
<
div
id
=”smsg”
>
if you see me in the alert msg,you win
</
div
>
</
body
>
</
html
>
html
>
<
head
>
<
script
src
=”jquery.js”
type
=”text/javascript”
></
script
>
<
script
type
=”text/javascript”
>
$(document).ready(
function
(){
$(
“
#btn
“
).click(
function
(){
var
mm
=
$(
‘
#mm
‘
, window.parent.document)
alert(mm.html())
})});
</
script
>
</
head
>
<
body
>
<
input
type
=”button”
id
=”btn”
value
=”click me “
/>
<
div
>
click the button above to get parent element’s innerHTML
</
div
>
<
div
id
=”smsg”
>
if you see me in the alert msg,you win
</
div
>
</
body
>
</
html
>
转载于:https://www.cnblogs.com/applesuch5/archive/2011/08/23/2150128.html
今天的文章iframe父子传值_js调用父页面方法分享到此就结束了,感谢您的阅读。
版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 举报,一经查实,本站将立刻删除。
如需转载请保留出处:https://bianchenghao.cn/78399.html