By registering with us, you'll be able to discuss, share and private message with other members of our community.
SignUp Now!Hi there,
The first thing to do when code is not working is to check the console. You would've seen that there are lots of errors.
The JavaScript in the script tag after that hamburger button is not valid. You can't put HTML inside script tags.
SORRY! i checked my file,not the published page... hamburger still wont work...Hi there,
The first thing to do when code is not working is tohttps://forallthetime.com/BI-D/rentals.html You would've seen that there are lots of errors.
i freely admit i know little JavaScript
i am almost finsihed wit this project
i immediately plan to learn dev tools, so you are aahead of right now 🙂
i alway validate my code on validaters
The JavaScript in the script tag after that hamburger button is not valid. You can't put HTML inside script tags.
anways, i got it to work! its fine now 🙂
thanks!
do i owe you a $0.25 now?
In your published page, as seen with View Source, you still have the HTML for the button inside theSORRY! i checked my file,not the published page... hamburger still wont work...
<script>
tag.<script>
function openNav() {
document.getElementById("mySidenav").style.width = "250px";
}
function closeNav() {
document.getElementById("mySidenav").style.width = "0";
}
<a href="#" class="hamburger-button" onclick="openNav()">?</a>
</script>
<script>
tag, make sure the page is reloaded (clear the browser cache to be sure, or add some cosmetic change so you're sure to be seeing the corrected page) and you will see your button spring into life.text/html
. Could be something with your webserver configuration. There's lots of results and solutions if you Google it. Or you could maybe try overriding this on the client side like this:<link rel="stylesheet" type="text/css" href="location.css">
<link rel="stylesheet" type="text/css" href="index.css">
thank you!In your published page, as seen with View Source, you still have the HTML for the button inside the<script>
tag.
JavaScript:<script> function openNav() { document.getElementById("mySidenav").style.width = "250px"; } function closeNav() { document.getElementById("mySidenav").style.width = "0"; } <a href="#" class="hamburger-button" onclick="openNav()">?</a> </script>
As @Johna pointed out, this needs to be corrected and you have not done that. As he also pointed out, you should have checked the console log and it looks like you have not done that either, because the messages are crystal clear about what the error is (the second one appears when you click the button):
View attachment 2571
Please correct your source code, move the button definition line outside the<script>
tag, make sure the page is reloaded (clear the browser cache to be sure, or add some cosmetic change so you're sure to be seeing the corrected page) and you will see your button spring into life.
I don't mean to sound pedantic, but if you ask for advice, and it is given to you, then by all means follow it. Saves you and us a lot of trouble.
I'm less sure about these other two errors shown in the console:
View attachment 2572
No idea why these two css files are deemed to have mime typetext/html
. Could be something with your webserver configuration. There's lots of results and solutions if you Google it. Or you could maybe try overriding this on the client side like this:
HTML:<link rel="stylesheet" type="text/css" href="location.css"> <link rel="stylesheet" type="text/css" href="index.css">
HTH.
<a href="#" class="closebtn" onclick="closeNav()"></a>
<button>
https://forallthetime.com/BI-D/rentals.html#
<button style="font-size:30px;cursor:pointer" onclick="openNav()">☰ </button>
...
<a href="#" class="hamburger-button" onclick="openNav()">?</a>
<a>
link. You need to decide which one you need to keep, and delete the other one. I would assume it's the one in the corner you want, but maybe not. Whether you use a <button>
or <a>
element is not so relevant, they work the same in this scenario. I would go for <button>
which is much clearer. Links are primarily intended to link to other pages.hamburger-button
is positioned where it is I don't know. You did not address these errors saying that your CSS files are not applied, and as long as your CSS doesn't work all bets are off with respect to appearance. Also, make up your mind whether you want to style elements in the HTML (as you did for the button) or in the CSS (as you did for the link). This has nothing to do with JavaScript, it's only a matter of being consistent and precise in your design and HTML code.thanks!Great that we have some progress. Yes, you have two "hamburger buttons", as you call them, both doing the same. Have you not asked yourself why that could be ? If you look at your code you see that there are two elements that open your hamburger menu:
HTML:<button style="font-size:30px;cursor:pointer" onclick="openNav()">☰ </button> ... <a href="#" class="hamburger-button" onclick="openNav()">?</a>
The first one is the 'real' button in the top left corner, the second one, some distance below it, is not actually not a button but a<a>
link. You need to decide which one you need to keep, and delete the other one. I would assume it's the one in the corner you want, but maybe not. Whether you use a<button>
or<a>
element is not so relevant, they work the same in this scenario. I would go for<button>
which is much clearer. Links are primarily intended to link to other pages.
Why this link with classhamburger-button
is positioned where it is I don't know. You did not address these errors saying that your CSS files are not applied, and as long as your CSS doesn't work all bets are off with respect to appearance. Also, make up your mind whether you want to style elements in the HTML (as you did for the button) or in the CSS (as you did for the link). This has nothing to do with JavaScript, it's only a matter of being consistent and precise in your design and HTML code.
flex
<body>
<button style="font-size:30px;cursor:pointer" onclick="openNav()">☰ </button>
...
<a href="#" class="hamburger-button" onclick="openNav()">?</a>
i have not adjusted every page of the site, that may be you are seeing 2I still see two hamburgers, same as before although I notice you have moved them around in your HTML code:
sorry for not clarifyingNo idea what you mean with "when I removed flex"
i chose link see here HomeMake up your mind which one you want, and whether to use a button or link.
there is no flex to be found, neither in the page source or in the Styles tab in the debugger.
Also, some of your CSS files are still being blocked as you can see in the console log. So you probably do not have all styling applied.
sieriously, i am grateful you wrote that!If you do not understand something, do ask.
that is my issue 🙂Sorry, it is not clear at all to me what your issue is now
No !!! Half the problem here is that you do not read properly. As I wrote, I am looking at what I believed to be the home page, in the link you posted at the very start start of this thread. It now seems that this is a different page from what you are working on. Anyway, let's focus on one and one page only for now, ok ?i have not adjusted every page of the site, that may be you are seeing 2
Yes, that's a different page than I was looking at all the time. At least that clears up the confusion about the two buttons, there's only one here. Still I think it is peculiar to use a link and then name its classi changed the display to flex, and that accomplished what i am after, but the code for placing the hamburger does not apply
i chose link see here Home
hamburger-button
.Ok, I see that now in style.css. But whether it's fixed or flex (I tried it out in the Developer Tools), the button does NOT move around when resizing the screen, as you suggested.that is beacuse i removed it, brought it back f to fixed
It should not be. Just press F12 to bring up Developer Tools (commonly known as "the debugger") and look for thei hope you can still help me here, again the console concept is foriegn to me at the moment...
Console
tab, see image. Any messages given there should have your full attention.Yes I see. The reason for that is because you have specified that position in style.css. If you keep itplease see where the hamburger is? its over the other code
fixed
but remove the top and left it seems quite ok to me :flex
, I still don't understand what exactly your problem is with that.I am not at all sure what you mean here.to be clear, i am after spacing out the hamburger fom the rest of my code on a smaller screen
it occured to me.... is that even possible?
Just press F12 to bring up Developer Tools (commonly known as "the debugger") and look for the Console tab, see image. Any messages given there should have your full attention.No !!! Half the problem here is that you do not read properly. As I wrote, I am looking at what I believed to be the home page, in the link you posted at the very start start of this thread. It now seems that this is a different page from what you are working on. Anyway, let's focus on one and one page only for now, ok ?
Yes, that's a different page than I was looking at all the time. At least that clears up the confusion about the two buttons, there's only one here. Still I think it is peculiar to use a link and then name its classhamburger-button
.
Ok, I see that now in style.css. But whether it's fixed or flex (I tried it out in the Developer Tools), the button does NOT move around when resizing the screen, as you suggested.
It should not be. Just press F12 to bring up Developer Tools (commonly known as "the debugger") and look for theConsole
tab, see image. Any messages given there should have your full attention.
View attachment 2579
Yes I see. The reason for that is because you have specified that position in style.css. If you keep itfixed
but remove the top and left it seems quite ok to me :
View attachment 2580
It also seems to work well withflex
, I still don't understand what exactly your problem is with that.
I am not at all sure what you mean here.
Great that you have fixed it and learned something along the way !Just press F12 to bring up Developer Tools (commonly known as "the debugger") and look for the Console tab, see image. Any messages given there should have your full attention.
thanks! i learned something new today!
any tips to make my site more aesthetically pleaseing.. make it look or function better? Thanks!
you may not believe this, but its true, before your latest post here i solved my own problem! seriously! i successfuly got my hamburger where i want it.. great minds, yes 🙂
No, not really. Sorry if I unwittingly gave that impression. I do admit I can get a bit frustrated when it seems like my posts (which I spend a lot of time on and take great care to be as precise and complete as possible) are not being read properly. It you want to be a good programmer, start by being a good reader. You know what really annoys me ? People who do not want to learn anything, do not want to make an effort, just expect someone to write their code and fix their problems for them. We see those types here all too often, alas. Luckily, you are not one of them otherwise I would have given up some time ago.i got the sense i have annoyed you 🙁 i dont know if that is the case... if thats real or perceived... i appologize to you in the most sinecere way... please know never once did i try to bug you! i am sorry if i frustrated you 🙁
Code Forum is a community platform where coding enthusiasts can connect with other developers, engage in discussions, ask for help, and share their knowledge with a supportive community. It's a perfect place to improve your coding skills and to find a community of like-minded individuals who share your passion for coding.
We use essential cookies to make this site work, and optional cookies to enhance your experience.