Click to See Complete Forum and Search --> : How to target javascript from another frame?


leonard_770
01-27-2003, 04:38 AM
I have a 2 framed page. In the bottom frame there are some buttons that I want to be able to call the javascript in the 'main' frame and change some of the variables within it.

Any ideas how I target the 'main' frame?

This is the original script;
<input type="button" value=" Increase Speed " onClick="slideShowSpeed-=500;if(slideShowSpeed<100){slideShowSpeed=100}" name="button">


This is what I tried but it didn't work;
<input type="button" value=" Increase Speed "
onClick="'parent.parent.frames[\'main\']', slideShowSpeed-=500;if(slideShowSpeed<100){slideShowSpeed=100}" name="button">

Thanks for your help.

khalidali63
01-27-2003, 08:26 AM
lookingat the code you posted,the first wrong item seems to be in here
onClick="'parent.parent.frames['main']',
don't use parent twice

onclick="parent.frames[frameIndex]
and then in your code after that is a "," comma.
If you are trying to call a JavaScript function in the main frame then this own't work you need to access the function like this
"parent.frames[frameIndex].document.functionName(parametersIfAny)"

It seems like you want to run a complete procedure here,the best approach will be to create a function in tthe JavaScript tags,inline code is hard to read(my opinion) and must not be used for complex routines.
Try the abovve and see,or else post your entire code here.

cheers

Khalid

leonard_770
01-27-2003, 09:19 AM
Hi khalidali63, I tried what you said but it still doesn't work,
so I'll post my script here.

This is the script from the 'main' frame;
<script>
<!--
=======================================

// Set slideShowSpeed (milliseconds)
var slideShowSpeed = 1000

// Specify the image files
var Pic = new Array() // don't touch this
// to add more images, just continue
// the pattern, adding to the array below

Pic[0] = 'images/010.jpg'
Pic[1] = 'images/001.jpg'
Pic[2] = 'images/002.jpg'
Pic[3] = 'images/003.jpg'
Pic[4] = 'images/004.jpg'
Pic[5] = 'images/005.jpg'
Pic[6] = 'images/006.jpg'
Pic[7] = 'images/007.jpg'
Pic[8] = 'images/008.jpg'
Pic[9] = 'images/009.jpg'

// =======================================
// do not edit anything below this line
// =======================================

var t
var j = 0
var p = Pic.length

var preLoad = new Array()
for (i = 0; i < p; i++){
preLoad[i] = new Image()
preLoad[i].src = Pic[i]
}

function runSlideShow(){
if (document.all){
document.images.SlideShow.style.filter="blendTrans(duration=2)"
document.images.SlideShow.style.filter="blendTrans(duration=crossFadeDuration)"
document.images.SlideShow.filters.blendTrans.Apply()
}
document.images.SlideShow.src = preLoad[j].src
if (document.all){
document.images.SlideShow.filters.blendTrans.Play()
}
j = Math.round(Math.random() * (p - 1));
t = setTimeout('runSlideShow()', slideShowSpeed)
}
//-->
</script>

and this is the script from the 'button' frame;
<form>
<div align="center">
<input type="button" value=" Decrease Speed " onclick="slideShowSpeed+=100">
<input type="button" value=" Increase Speed " onClick="'slideShowSpeed-=100;if(parent.main.slideShowSpeed<100){slideShowSpeed=100}" name="button">
</div>
</form>

Thanks for any help that you can give me.

librab103
01-27-2003, 11:29 AM
I a have a link inside an iframe that I want to make the parent or main window to close when I click the link. And I have another link that I want the parent or main window to minimize.

Thanks a bunch

khalidali63
01-27-2003, 07:03 PM
try this link,See if thats what that can help you.
http://68.145.35.86/skills/javascripts/frames/ParentChildFramesInteraction.html
Khalid

leonard_770
01-28-2003, 03:17 AM
Originally posted by khalidali63
try this link,See if thats what that can help you.
http://68.145.35.86/skills/javascripts/frames/ParentChildFramesInteraction.html
Khalid

This link doesn't load?

khalidali63
01-29-2003, 11:14 AM
I just tried it,link does seem to work.

Khalid