(e-mail address removed) said on 17/03/2006 4:20 PM AEST:
hi ppl..
i'm new to jsp and iframes.. and here is what i want to do - take
I guess you're asking how to load it directly into the iFrame without
going back to the server using JavaScript.
input from the user in a form, and load an iframe with that url..
any suggestions?
Set the location attribute of the iFrame to the value of the input text.
You may want to do some validation on the input string to make sure it
looks a bit like a URL first.
If JavaScript is disabled, the form will be submitted so have your
server return the page.
<script type="text/javascript">
function loadFrame(el)
{
var f;
var fName = el.form.target;
if (fName && (f = window.frames) && (f = f[fName])){
f.location = el.value;
return false;
}
return true;
}
</script>
<form action="" target="foo"
onsubmit="return loadFrame(this.URL);"><p>
<input type="text" size="100" name="URL"><input
type="submit" value="Load URL">
</p></form>
<iframe id="foo" name="foo" width="50%"></iframe>
Of course if you use links, you don't need script at all:
<a href="
http://www.apple.com/" target="foo">Load Apple in foo</a>