/    Sign up×
Community /Pin to ProfileBookmark

Targeting multi Iframes

I asked over in the HTML Forum if there was a way to target two I-frames (one for actual web content, the other for an image) using a single nav button. (I’m still a newbie, so pardon if I don’t get all the terminology down). They said it can’t be done without some Java Scripting. Can anyone help me out, or point me to a good tutorial to go through?

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@IceMetalPunkMar 09.2004 — Sure. you could do this:

[code=php]
<script>
function ChangeFrames() {
document.getElementById("frame1").src="URL_TO_PAGE";
document.getElementById("frame2").src="URL_TO_IMAGE";
}
</script>
[/code]


Then, have the IFrames and button like this:

[code=php]
<iframe id="frame1"></iframe><iframe id="frame2"></iframe><input type="button" value="Change IFRAMES" onClick="ChangeFrames()">
[/code]


Hope this helps.

-IceMetalPunk ?
Copy linkTweet thisAlerts:
@steelersfan88Mar 09.2004 — I replied to that, i'll try and make myself a tad clearer!

If you want on a button click to change the source of two iframes, you have 2 choices, either put the code right into the onclick event or put it neatly into a function, like so:[code=php]<form name="myForm">
<input type="button" value="Change" onclick="makeChange()">
</form>

<script type="text/javascript">

// note this should be in the head section
// not quite sure what you want to do with the function, this will just change the source:

function makeChanges() {
document.frames['leftFrame'].document.location.href = "where"
document.frames['picFrame'].document.location.href = "other where.gif"
}

</script>[/code]
Remember, the goal of changing the sources is simple, yet it is difficult from your post to see actually what you want it to do. If there are several buttons, call the same function and send a parameter to the picture and page you want to display, which would be retrieved from an array, respond if more help needed.
Copy linkTweet thisAlerts:
@LetterBauthorMar 09.2004 — Thanks to both of you. I'll play around with both ideas and see if I can get something working.
×

Success!

Help @LetterB 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,
)...