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 biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

neat javascript - problem though 1

Status
Not open for further replies.

altaratz

ISP
Apr 15, 2001
73
US
Here's one for everyone - a floating url bar, just type in the url, and go - however, could someone please point out how to make it load into the "main frame, and not the one I'm putting it in - thanks!

<Script language=&quot;Javascript&quot;>
function goto()
{
var Form_field;
var Form_field = document.Go.To.value;
var Goto=(Form_field);
this.location.href = Goto;
}
</script>
<TITLE></TITLE>
</HEAD>
<BODY BGCOLOR=&quot;FFFFF&quot; TEXT=&quot;00000&quot;>
<!--[if IE]>
<div id=&quot;scontentmain&quot;>
<div id=&quot;scontentbar&quot; >
<img align=&quot;right&quot; src=&quot;barbutton.gif&quot; onClick=&quot;onoffdisplay()&quot;>
</div>
<div id=&quot;scontentsub&quot;>


<div align=&quot;right&quot;><form action=&quot;javascript:goto()&quot; name=&quot;Go&quot;>
<b>Input a url here:</b> <input type=&quot;text&quot; size=&quot;45&quot; name=&quot;To&quot; value=&quot;<input type=&quot;button&quot; value=&quot;Goto It!&quot; onClick=&quot;goto()&quot;>
</form></div>
 
Yes.

Change &quot;this.location.href&quot;.

&quot;this&quot; should be replaced by the name of the frame.

Later. I hope this helped! ;-)
- Casey Winans
 
Change &quot;this.location.href&quot;

to

parent.framename.location = &quot;someurl&quot;

as location.href is better used to retrieve a string and causes problems when set at times

if you want to set the current frame, just use

self.location = &quot;someurl&quot; jared@eae.net -
 
I tried both of those, and neither worked. I'll post one last time, the whole code, as is, in hopes someone can find the error - the javascript is located in the &quot;up&quot; frame, and the target frame is &quot;main&quot; located as a sub-frame of &quot;middle&quot; frame. Thanks in advance again!

<Script language=&quot;Javascript&quot;>
function goto()
{
var Form_field;
var Form_field = document.Go.To.value;
var Goto=(Form_field);
parent.main.location = &quot;Goto&quot;;
}
</script>

<TITLE></TITLE>
<META name=&quot;description&quot; content=&quot;&quot;>
<META name=&quot;keywords&quot; content=&quot;&quot;>
<META name=&quot;generator&quot; content=&quot;CuteHTML&quot;>
</HEAD>
<BODY BGCOLOR=&quot;#FFFFFF&quot; TEXT=&quot;#000000&quot; LINK=&quot;#0000FF&quot; VLINK=&quot;#800080&quot;>
<HTML>
<HEAD>
<img src=&quot; height=100% width=100% borderwidth=0 hspace=0 vspace=0></BODY>
<!--[if IE]>
<div id=&quot;scontentmain&quot;>
<div id=&quot;scontentbar&quot; >
<img align=&quot;right&quot; src=&quot;barbutton.gif&quot; onClick=&quot;onoffdisplay()&quot;>
</div>
<div id=&quot;scontentsub&quot;>


<div align=&quot;right&quot;><form action=&quot;javascript:goto()&quot; name=&quot;Go&quot;>
<b>Input a url here:</b> <input type=&quot;text&quot; size=&quot;45&quot; name=&quot;To&quot; value=&quot;<input type=&quot;button&quot; value=&quot;Goto It!&quot; onClick=&quot;goto()&quot;>
</form></div>
 
var Form_field = document.Go.To.value;
var Goto=(Form_field);
parent.main.location = &quot;Goto&quot;;

should read:

var Form_field = document.Go.To.value;
parent.main.location = Form_field; jared@eae.net -
 
Thank you to both of you guys for th suggestions - I guess this is one script that's just not meant to target frames (this.location.href works fine within a frame though :(

Anyways, take it easy.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top