/    Sign up×
Community /Pin to ProfileBookmark

I’m not exactally sure how to this but, I’m looking for a way to change the source of an iframe, by selection of an option box. A link would work too, but I’d prefer the first way.

Thanks in advance.

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@micjohnsonJul 12.2003 — <SCRIPT language=JavaScript>

var i=null

function go (){

if (i != null){}


y=i;

document.getElementById('1').innerHTML = '<iframe src="+y+"></iframe>'

}

</SCRIPT>

put that in your head

<div id=1></div>

put that in your body where you want the iframe to be when it is chosen

add the the code of your option i=("http://www.thesiteyouwant.com")
Copy linkTweet thisAlerts:
@CharlesJul 12.2003 — [font=georgia]JavaScript will fail for 13% of users leaving you looking awfully silly with broken navigation on your site. And there's no need to use JavaScript here.[/font]

[font=monospace]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"

"http://www.w3.org/TR/html4/loose.dtd">

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<title>Example</title>

<div><iframe name="spec" src="http://www.w3.org/"></iframe></div>

<div><a href="http://www.w3.org/TR/html401/" target="spec">HTML 4.01</a> | <a href="http://www.w3.org/TR/xhtml1/" target="spec">XHTML 1.0</a> | <a href="http://www.w3.org/TR/xhtml11/" target="spec">XHTML 1.1</a></div>[/font]
Copy linkTweet thisAlerts:
@obviousunknownauthorJul 12.2003 — I've got this for the script in the head:

<script>

go(source)

{

document.getElementById("ifrm").src = source;

}

</script>

Then i have this in the body:

<iframe src="" id="ifrm">

<a href="javascript:go('http://www.yahoo.com');">Yahoo!</a>

<a href="javascript:go('http://www.google.com');">Google</a>


-------
How would I do the same effect, but using an option box instead of a link? Something like this?

<select>

<option onClick="javascript:go('http//www.yahoo.com');">Yahoo!</option>

<option onClick="javascript:go('http//www.google.com');">Google</option>

</select>
Copy linkTweet thisAlerts:
@CharlesJul 12.2003 — [font=monospace]<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"

"http://www.w3.org/TR/html4/strict.dtd">

<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

<form action="cgi-bin/url.pl" target="spec">

<div>

<select name="url.pl">

<option value="http://www.w3.org/TR/html4/">HTML 4.01</option>

<option value="http://www.w3.org/TR/xhtml1/">XHTML 1.0</option>

<option value="http://www.w3.org/TR/xhtml11/">XHTML 1.1</option>

</select>

<button type="submit">Send me</button>

</div>

</form>

[font=georgia]And the Perl script url.pl would look something like:[/font]

#!user/local/bin/perl

use CGI qw(redirect param);

print redirect param 'url';[/font]
Copy linkTweet thisAlerts:
@obviousunknownauthorJul 13.2003 — cgi, nevermind, I'll fool around with different ideas. thanks though.
×

Success!

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