Jump to content

HTML buttons


wowowlop1

Recommended Posts

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!

post-127230-0-60773500-1362695411_thumb.png

Link to comment
Share on other sites

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

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

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

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

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 by wowowlop1
Link to comment
Share on other sites

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

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
1. 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

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 by thescientist
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...