Link to home
Start Free TrialLog in
Avatar of rw263
rw263

asked on

Call Parent Frame JavaScript

--- I have a frame HTML page: ----------------------------------------------
<frameset rows="74,*">
 <frame src="header.html" name=header>
 <frame src="body.html" name=body>
</frameset>

--- in the header.html 'script' section I have functions: ------------------
function click(imageLoc)
function headerRollOut(num)
function headerRollOver(num)
function navigatorRoll(mousePos)

Now for the question.  I want to call the functions in the header.html (header) page from the html in the body.html (body) page.  That is I don't choose to repeat all my functions that I wrote in my header.html in my body.html.  I don't want the same code in both areas.  Is there something like:
         parent.frames['header'].click(imageLoc)
that will call a javascript function from another frame?  Please help!  Thanks so much!  How the heck do I do this??
Avatar of sybe
sybe

yes, it should work as you described.

maybe it is even easier to write the functions (and varibles if you want) in the frameset-page.

================

<script>
var MyVar1 = ...

function MyFunction1() {}
function MyFunction2() {}
function MyFunction3() {}
</script>

<frameset rows="74,*">
<frame src="header.html" name=header>
<frame src="body.html" name=body>
</frameset>

=================

you can call from the frames by:

parent.MyFunction1()

and access variables like

newvar = parent.Myvar1


Avatar of rw263

ASKER

I kept the script in the header.html and called the script from the body.html like: onMouseOver="parent.header.navigatorRoll('Over')" and it doesn't work.  If I have in the header.html onMouseOver="navigatorRoll('Over')" it works.  How do I call the SAME script from a different frames html?

It supposes to be work nice. Can you post your script? It may be help.
ASKER CERTIFIED SOLUTION
Avatar of alamo
alamo

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of rw263

ASKER

Sorry, my bad, the original suggestion did work, I didn't know how to recall my bad reply.  I originally had local problems and that is what caused it.  Thanks for all the help!!!