Old 16-09-2003, 05:34   #1 (permalink)
dan
Iris Folder
 
dan's Avatar
 
Join Date: Apr 2003
Location: smokey
Posts: 2,675
Javascript frame targeting

Right - some simple Javascript here that I'm stumbling around all over

It's more complicated than this but the crux of what I'm doing is as follows.

I have an html page containing 2 frames. A & B
I need to extract a variable from a script within one frame using a script in the other.

Frame A Script...

<script type="text/javascript">
var test = "hello?";
</script>

Frame B Script...

<script type="text/javascript">
function targetTest {
alert(parent.A.test + "- yes I'm here");
}
</script>

I call targetTest() from an onClick event.

<a href="#" onClick="targetTest();"> CLICK TO TEST </a>


[edit] it would appear that the above code is in fact fine [/edit]



I've obviously got this wrong, doesn't work test is always undefined - help!

Never really sure where to post these, guess it should really be in the Programming section, move it if that's where it should live Been trying to find examples on Javascriptsource.com etc but to no avail, it's probably just too simple a problem...

Last edited by dan : 16-09-2003 at 06:09.
  Reply With Quote
Old 16-09-2003, 06:52   #2 (permalink)
Bill Posters
trouble free and loverlee
 
Join Date: Mar 2003
Location: YooKay
Posts: 2,937
Code:
function targetTest() { alert(parent.frames['A'].test +" - yes, I'm here"); }

You're also (possibly) forgetting to add the parentheses to the targetTest function name.


<aside>

Are frames really necessary?
Do the pros of using them in this case outweigh the cons?

</aside>
  Reply With Quote
Old 16-09-2003, 10:22   #3 (permalink)
dan
Iris Folder
 
dan's Avatar
 
Join Date: Apr 2003
Location: smokey
Posts: 2,675
Thanks Bill, i'll make those changes (seems to be working anyway at the moment?)

In response to the aside...

It really isn't my choice. I'm Rewritting styles for a large Asset Management system (webNative - http://www.Xinet.com) and as far as development options go it is by far the easiest. I am not a Javascript programmer, Actionscript and php are where my skills lie. They may be related but it's still causing me some difficulty and I'm learning on the fly.

and this thing is a beast, file after file of code, not fun.

Welcome to my ( - current - ) nightmare...
  Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search


Contact Us - Web Design Forums - Archive - Top
Search Engine Optimization by vBSEO 3.0.0 RC8