/    Sign up×
Community /Pin to ProfileBookmark

How to target javascript from another frame?

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.

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@khalidali63Jan 27.2003 — 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
Copy linkTweet thisAlerts:
@leonard_770authorJan 27.2003 — 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.
Copy linkTweet thisAlerts:
@librab103Jan 27.2003 — 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
Copy linkTweet thisAlerts:
@khalidali63Jan 28.2003 — try this link,See if thats what that can help you.

http://68.145.35.86/skills/javascripts/frames/ParentChildFramesInteraction.html

Khalid
Copy linkTweet thisAlerts:
@leonard_770authorJan 28.2003 — [i]Originally posted by khalidali63 [/i]

[B]try this link,See if thats what that can help you.

http://68.145.35.86/skills/javascripts/frames/ParentChildFramesInteraction.html

Khalid [/B]
[/QUOTE]


This link doesn't load?
Copy linkTweet thisAlerts:
@khalidali63Jan 29.2003 — I just tried it,link does seem to work.

Khalid
×

Success!

Help @leonard_770 spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...