Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
341 views
in Technique[技术] by (71.8m points)

javascript - Calling a function in parent file from child frame?

I have a function that resizes the col width ratio of my frameset in "frame.html":

<frameset id="set" cols="*,*" FRAMESPACING=0 BORDER=3 BORDERCOLOR=#eeeeee>
    <frame src="index.html">
    <frame src="index2.html"> 
    <noframes></noframes> 
</frameset> 

The function works fine when called from "frame.html", However i want to call said function from the child file "index.html"... the function needs to remain in the parent file in order to run properly... How can I call my function in frame.html from index.html

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Just try parent.functionName() it should work.

Edit


Just to be sure that the scope is correct you should probably call window.parent.functionName() instead to be sure that it is actually the frames parent that is referenced

Edit 2


Check out this answer it seems to handle the same chrome issue.

Hope it helps!


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...