944,201 Members | Top Members by Rank

Ad:
You are currently viewing page 1 of this multi-page discussion thread
Jun 26th, 2005
0

window location using frames

Expand Post »
Hey all.
I have been messing around with javascript for a while now and I am not all too good with it. I built a little javascript program that takes the input from a text box and depending on what's in there, it goes to a certain page. I am using
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. window.location("url here");
my problem is that I have this script loaded on a page with frames and this loads in the top frame. When the script is executed, it opens the new page in the top frame, but I need it to open the page in the bottom frame. Can anyone help me understand how to do this? Thanks in advance.
-Nick
Similar Threads
Reputation Points: 18
Solved Threads: 4
Junior Poster
stupidenator is offline Offline
192 posts
since Mar 2005
Jun 26th, 2005
0

Re: window location using frames

I'm not sure where the concept of "bottom" fits within the frame hierarchy. But you can refer to specific frames using an indexer of the frame collection:

frames[1], frames[2], and so on.

Also look at the "top" and "parent" objects, and possible the "this" keyword, the "self" object, and so on. Seeing some code would help us help you.
Team Colleague
Reputation Points: 227
Solved Threads: 37
Made Her Cry
tgreer is offline Offline
1,697 posts
since Dec 2004
Jun 27th, 2005
0

Re: window location using frames

here is the code for it.

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <SCRIPT LANGUAGE="JavaScript">
  2.  
  3. <!-- Begin
  4. var g;
  5. function track()
  6. {
  7. g=document.log1.T1.value;
  8.  
  9. if (g.length == 18 || g.length == 24) { window.location="http://wwwapps.ups.com/WebTracking/processInputRequest?InquiryNumber1="+g+"&AgreeToTermsAndConditions=yes&track.x=22&track.y=4"; }
  10. else { window.location="http://search.ebay.com/search/search.dll?satitle="+g; }
  11.  
  12. }
  13. // End -->
  14. </script>

when the submit button is pressed, it calls the track() method and with the way it is set up now, it opens it in the same frame. I need to be able to have the script open it in another frame. Thanks for your help!
Nick
Reputation Points: 18
Solved Threads: 4
Junior Poster
stupidenator is offline Offline
192 posts
since Mar 2005
Jun 27th, 2005
0

Re: window location using frames

Thanks. We'll need to see your stripped-down frameset code, so we can see how many frames you have, their relationship to each other, the IDs you've given them, and so on.
Team Colleague
Reputation Points: 227
Solved Threads: 37
Made Her Cry
tgreer is offline Offline
1,697 posts
since Dec 2004
Jun 27th, 2005
0

Re: window location using frames

Here is the frameset page. Thanks for your help.
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Frameset//EN" "http://www.w3.org/TR/html4/frameset.dtd">
  2. <html>
  3. <head>
  4. <title></title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  6. <link REL="shortcut icon" HREF="images/icon.jpg" TYPE="image/x-icon">
  7. </head>
  8.  
  9. <frameset rows="115,*" frameborder="NO" border="1" framespacing="0">
  10. <frame src="header.html" name="topFrame" scrolling="NO" noresize >
  11. <frame src="home.html" name="mainFrame">
  12. </frameset>
  13. <noframes><body>
  14. <h2><center>Your Browser does not support Frames which are in use on the page you are trying to view. Please re-adjust your browser and try again. Thank you.</center></h2>
  15.  
  16.  
  17. </body></noframes>
  18. </html>
Nick
Reputation Points: 18
Solved Threads: 4
Junior Poster
stupidenator is offline Offline
192 posts
since Mar 2005
Jun 27th, 2005
0

Re: window location using frames

Modify your window.location statement in your track() procedure to reference a specific frame, rather than the entire "window":

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. top.frames["mainFrame"].location.href="www.tgreer.com";
Team Colleague
Reputation Points: 227
Solved Threads: 37
Made Her Cry
tgreer is offline Offline
1,697 posts
since Dec 2004
Jun 27th, 2005
0

Re: window location using frames

Thank you very much for the help. It does work! But if I can ask one more quesiton, I am not really understanding the 'top' call in
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. top.frames["frame"].location="www.com";
Could you maybe explain that a little bit? Thank you for replying
Nick
Reputation Points: 18
Solved Threads: 4
Junior Poster
stupidenator is offline Offline
192 posts
since Mar 2005
Jun 27th, 2005
0

Re: window location using frames

"Top" is the top-level window object in the hierarchy. Think of it as your "frameset" page.

So "top" contains all of your frames. You're saying, "go to the top window object, look into all the frames it contains, find the one named 'mainFrame', and set that frame's location to the URL 'www.tgreer.com'.
Team Colleague
Reputation Points: 227
Solved Threads: 37
Made Her Cry
tgreer is offline Offline
1,697 posts
since Dec 2004
Jun 27th, 2005
0

Re: window location using frames

Thanks a lot! I understand that now!
-Nick
Reputation Points: 18
Solved Threads: 4
Junior Poster
stupidenator is offline Offline
192 posts
since Mar 2005
Jun 27th, 2005
0

Re: window location using frames

You're welcome!
Team Colleague
Reputation Points: 227
Solved Threads: 37
Made Her Cry
tgreer is offline Offline
1,697 posts
since Dec 2004

This thread is solved

Either the thread starter or a moderator has marked this thread as solved. You can most likely trust the responses and answers given. There is most likely no reason for any further responses to be posted here. If you have a related question, please start a new thread in this forum instead.

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in JavaScript / DHTML / AJAX Forum Timeline: display value in text box using ajax
Next Thread in JavaScript / DHTML / AJAX Forum Timeline: window.open not workin in firefox





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC