简体   繁体   中英

javascript window.location page redirect in frames

I'm learning javascript from an old book (2003) so i think some of the code is obsolete and i know frames aren't good practice but im having trouble with the last exercise in the book.

The top page has 2 frames, a left and right. The left acts as a menu bar and stays the same. One of the right pages has a form to fill and onclicking the submit it calls a function which should then change just the right page using window.location.href="nextpage.html" but it doesn't work. Any ideas? I've played around with it for ages. I can change the main frameset holding page but not just the right one.

Thanks for your help

If you are changing a frame from another frame then you will need to do something like

parent.left_frame.location="next1.html";
parent.right_frame.location="next2.html";

(note: the parent is the key to it all)

I would look into jquery and ajax requests but learning basic javascript is definitely useful first.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM