页面之间互相调用javascript函数?

xzb_97 2009-06-18 11:07:20
我在页面main.asp中有一个<ifram src="test.asp" name="test">和<ifram src="call.asp" name="call">。
test.asp中有一个javascript函数getmsgflag,请问在页面call.asp中如何调用getmsgflag,谢谢大家指教 !
...全文
70 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
xzb_97 2009-06-18
  • 打赏
  • 举报
回复
谢谢,我的getmsgflag函数里有个id,能不能在call.asp里赋值?
toury 2009-06-18
  • 打赏
  • 举报
回复
test.asp

<script>
function getmsgflag(){
alert("call 调用我")
}
//getmsgflag()
</script>


call.asp

<script>
window.parent.test.getmsgflag()
</script>
xzb_97 2009-06-18
  • 打赏
  • 举报
回复
哪位大侠指点一下迷津,急!
xzb_97 2009-06-18
  • 打赏
  • 举报
回复
不用onclick等,直接parent.test.getmsgflag行不行?
xzb_97 2009-06-18
  • 打赏
  • 举报
回复
呵呵,谢谢,放分!
toury 2009-06-18
  • 打赏
  • 举报
回复
test.asp

<script>
function getmsgflag(id){
alert("call 调用我,并给我赋值" + id)
return "old"//为什么是“old”,不是参数id?不明白,呵呵
}
</script>


call.asp

<script>
var newID=window.setTimeout("refmessage()",1000)
function refmessage(){
var flag=window.parent.test.getmsgflag(newID);
if (flag=="old"){
location.href = "call.asp";
alert("!")
}
var id=window.setTimeout("refmessage()",1000)
}


  • 打赏
  • 举报
回复
这个调用不了啊
晕!服务端的代码你怎么能调用

只有客户端的代码才会存在父子或者子窗口与子窗口之间的调用
xzb_97 2009-06-18
  • 打赏
  • 举报
回复
那我后面的这段代码是不是写的有问题?
number123456 2009-06-18
  • 打赏
  • 举报
回复
parent.test.getmsgflag

解释:
parent 父框架
test test对像
getmsgflag JavaScript 方法

连起来就是,父框架中的test对像中的getmsgflag方法
所以,你可以在call.asp中用这个方法任意调用getmsgflag,包括带参数,效果等同在test.asp中使用getmsgflag效果
xzb_97 2009-06-18
  • 打赏
  • 举报
回复
源码是这样的:在test.asp里:

function getmsgflag()
dim msgflag
msgflag = "old"
getmsgflag = msgflag
end function

call.asp里:

newID=window.setTimeout ("refmessage",10000)
sub refmessage
if window.parent.test.getmsgflag = "old" then
location.href = "call.asp"
alert("!")
end if
ID=window.setTimeout ("refmessage",10000)
end sub

可是页面没反应,是写错了吗?

toury 2009-06-18
  • 打赏
  • 举报
回复
[Quote=引用 4 楼 xzb_97 的回复:]
谢谢,我的getmsgflag函数里有个id,能不能在call.asp里赋值?
[/Quote]
当然可以,给函数加个参数就可以了
test.asp
<script>
function getmsgflag(id){
alert("call 调用我,id参数是"+id)
}
//getmsgflag()
</script>


call.asp
<script> window.parent.test.getmsgflag(123) </script>

28,406

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧