Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Rhinorhino on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Please Tweak This (URL target)

Status
Not open for further replies.
Joined
Apr 7, 2006
Messages
10
Location
US
I have the following code, but I want it so that when I click "Go" the URL loads in an iframe (iframe's name="frame1).
_____________________________________________
<script type="text/javascript">
function goToURL(form) {
query = form.query.value;
if(query == null || query == "") {
alert("Error: Missing URL");
return false;
}
document.location.href = query;
return false;
}
</script>



<form onsubmit="return goToURL(this)" action="">
<input name="query" type="text" size="50" maxlength="255" value=" />
<input type="submit" value="Go"/>
</form>
<br>
<iframe name="frame1" src=" width="1024" height="768"></iframe>
_____________________________________________
 
>[tt] document.location.href = query;[/tt]
[tt] window.frame1.location.href = query;[/tt]
 
Try:

Code:
document.getElementByName("frame1").src = query;
 
>Look at it refined...
what's in there?
 
Now it's just refreshing (see above "refined" link...it's been updated).

In the refined thing, i was just showing what it did after I added your code.
 
Why don't you post it here?
 
<script type="text/javascript">
function goToURL(form) {
query = form.query.value;
if(query == null || query == "") {
alert("Error: Missing URL");
return false;
}
document.getElementByName("frame1").src = query;
document.location.href = query;
return false;
}
</script>



<form onsubmit="return goToURL(this)" action="" target="frame1">
<input name="query" type="text" size="50" maxlength="255" value=" />
<input type="submit" value="Go"/>
</form>
<br>
<iframe name="frame1" src=" width="500" height="250"></iframe>
 
Did you read my first reply? Or you don't want to follow for other reason; or maybe you are not answering me, but Kirsle?
 
You want the URL to load in the iframe - which you're doing with this line:

Code:
document.getElementByName("frame1").src = query;

but immediately after it, you have this line:

Code:
document.location.href = query;

which will clear the current page, removing the iframe.

If you want to load into the iframe, why have the second line? It makes no sense.

Dan



[tt]Dan's Page [blue]@[/blue] Code Couch
[/tt]
 
tsuji, yes, I read your first post. I tried it, and it still refuses to work correctly.

BillyRayPreachersSon, even when I delete the second line mentioned, it still doesn't work.
 
*sigh* Okay, since nobody seems to know how to tweak it, would anybody mind to just make another one?

__________________________________
<script type="text/javascript">
function goToURL(form) {
query = form.query.value;
if(query == null || query == "") {
alert("Error: Missing URL");
return false;
}
document.frames['frame1'].src = query;
}
</script>



<form onsubmit="return goToURL(this)" action="" target="frame1">
<input name="query" type="text" size="50" maxlength="255" value=" />
<input type="submit" value="Go"/>
</form>
<br>
<iframe name="frame1" src=" width="500" height="250"></iframe>
__________________________________
 
They keep saying not working, not working...
[tt]
<html>
<head>
<script type="text/javascript">
function goToURL(form) {
query = form.query.value;
if(query == null || query == "") {
alert("Error: Missing URL");
return false;
}
window.frame1.location.href = query;
return false;
}
</script>
</head>
<body>
<form onsubmit="return goToURL(this)" action="">
<input name="query" type="text" size="50" maxlength="255" value=" />
<input type="submit" value="Go"/>
</form>
<br>
<iframe name="frame1" src=" width="500" height="250"></iframe>
</body>
</html>
[/tt]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top