wowowlop1 Posted March 7, 2013 Share Posted March 7, 2013 Hey guys, I have a website that I'm making for a friend, and he wants the Top Bar to be a navigation bar. I put a button up there with: <button onclick="window.location.href='Main.htm'">Home</button> but it opens the website in the top bar, not in the main bar. I attached a picture of the website, and if I forgot any important information, please tell me. Thanks! Link to comment Share on other sites More sharing options...
jeffman Posted March 8, 2013 Share Posted March 8, 2013 1. Let's be clear. Frames are a 1990s dinosaur and no sane person uses them. There are better ways to achieve the same effect. Please, please look into it. 2. A frame is essentially a window object. Any reference to "window" that you grab inside a frame refers to the frame itself. What you want is a reference to the other frame. The code for that is ugly. 3. In the document where you define the frameset, give the frame a name. Not an id. A name. For this lesson, let's call it "main". From any other frame, your code looks like this: onclick="window.parent.frames['main'].location.href='Main.htm'" If you're using iFrames, it might be a little different. I don't remember exactly. I live in the 21st century. Link to comment Share on other sites More sharing options...
wowowlop1 Posted March 8, 2013 Author Share Posted March 8, 2013 Hey guys, I have a website that I'm making for a friend, and he wants the Top Bar to be a navigation bar. I put a button up there with: <button onclick="window.location.href='Main.htm'">Home</button> but it opens the website in the top bar, not in the main bar. I attached a picture of the website, and if I forgot any important information, please tell me. Thanks! But that didn't answer my questions about the buttons. Link to comment Share on other sites More sharing options...
jeffman Posted March 8, 2013 Share Posted March 8, 2013 Then rephrase your question. Link to comment Share on other sites More sharing options...
wowowlop1 Posted March 8, 2013 Author Share Posted March 8, 2013 Then rephrase your question.How do i get the buttons in the top bar to change the webpage in the main bar? Link to comment Share on other sites More sharing options...
jeffman Posted March 8, 2013 Share Posted March 8, 2013 That is the question I answered. Have you tried it? If it didn't work, can you explain how it didn't work? Link to comment Share on other sites More sharing options...
wowowlop1 Posted March 8, 2013 Author Share Posted March 8, 2013 That is the question I answered. Have you tried it? If it didn't work, can you explain how it didn't work?I entered the code you provided as an alternative for my button, but the button just disappeared on the website. Am I missing another line? Link to comment Share on other sites More sharing options...
jeffman Posted March 8, 2013 Share Posted March 8, 2013 Can you provide a live link to this page? If not, post the code? Link to comment Share on other sites More sharing options...
wowowlop1 Posted March 8, 2013 Author Share Posted March 8, 2013 <html><head><title>Top</title></head><body><body background="TopBackground.gif"><img src="STWars.gif" alt="gold"><onclick="window.parent.frames['main'].location.href='Main.htm'"> Link to comment Share on other sites More sharing options...
jeffman Posted March 8, 2013 Share Posted March 8, 2013 I assumed you would realize that my onclick code was meant to replace your onclick code, not the entire button tag. The button I hoped you would create would look like this: <button onclick="window.parent.frames['main'].location.href='Main.htm'">Home</button> Link to comment Share on other sites More sharing options...
wowowlop1 Posted March 8, 2013 Author Share Posted March 8, 2013 (edited) I assumed you would realize that my onclick code was meant to replace your onclick code, not the entire button tag. The button I hoped you would create would look like this: <button onclick="window.parent.frames['main'].location.href='Main.htm'">Home</button> So how do I name the frame 'main' The current code is: <frame src="Main.htm" noresize="noresize"> Edited March 9, 2013 by wowowlop1 Link to comment Share on other sites More sharing options...
STWars Posted March 9, 2013 Share Posted March 9, 2013 1. Let's be clear. Frames are a 1990s dinosaur and no sane person uses them. There are better ways to achieve the same effect. Please, please look into it. so why dont you tell him an alternative to framesets instead of giving him the knowledge of the alternatives existence? seems a bit counterproductive if you ask me Link to comment Share on other sites More sharing options...
jeffman Posted March 9, 2013 Share Posted March 9, 2013 so why dont you tell him an alternative to framesets instead of giving him the knowledge of the alternatives existence?seems a bit counterproductive if you ask me1. I would need to know a lot more information before I could recommend the best one.2. Even describing without explanation takes a while.3. I assumed this thread would be done after Post #24. I presume wowowlop1 is an adult who can ask what he/she wants to know Link to comment Share on other sites More sharing options...
jeffman Posted March 9, 2013 Share Posted March 9, 2013 So how do I name the frame 'main' Assuming this is correctly nested in a frameset, just add a name property: <frame src="Main.htm" noresize="noresize" name="main"> Link to comment Share on other sites More sharing options...
thescientist Posted March 9, 2013 Share Posted March 9, 2013 (edited) so why dont you tell him an alternative to framesets instead of giving him the knowledge of the alternatives existence? seems a bit counterproductive if you ask me and the help you're offering is what, exactly? DD provided the answer to the OP's question and more. People in development should possess the ability to reach out and ask questions for themselves if they seek further assistance or guidance on a topic. Edited March 9, 2013 by thescientist Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now