Whats wrong with this code?
I have not any errors from ie.
<html>
<script type="text/javascript">
var a = 1;
var b = 2;
if (a < b) {
document.write("CONDITION TRUE :D")
} else {
document.write("CONDITION IS FALSE D:")
</script>
So?
Whats wrong with this code?
I have not any errors from ie.
<html>
<script type="text/javascript">
var a = 1;
var b = 2;
if (a < b) {
document.write("CONDITION TRUE :D")
} else {
document.write("CONDITION IS FALSE D:")
</script>
So?
Your else branch is missing a closing }.
As a tip for the future: Many browsers have some sort of Javascript console, which lists any errors that were encountered while trying to execute the Javascript on the current page. Looking at the messages in that console will help you find errors like this quickly.
Many browsers have some sort of Javascript console
Where can I find that console?
I use Mozilla Firefox btw.
In Firefox it's in the menu under Tools -> Web Developer -> Web Console (shortcut: Ctrl + Shift + K).
IE9 also has some built in developer tools...hit F12. I do prefer Firefox tools though.
You can also just right click and hit "Inspect Element" then click on console when it pops up.
This only works for firefox, chrome, and safari, I'm not sure about IE, but there's just a different method of getting to the console in IE.
This only works for firefox, chrome, and safari,
Not true, not for firefox any way - only for Chrome though.
Hmmm, really? Are you using a current version of firefox?
Are you using a current version of firefox?
Yes, yes I am. I am running version 9.0.1.
Hmmmm, I'm not using Firefox right now, but if I remember correctly, Firefox should let you inspect element. I even remember a cool little popout 3D code thing with Firefox...
if I remember correctly, Firefox should let you inspect element
No, it does not. When I right click on any page I have options:
"Back"
"Forward"
"Reload Page"
"Stop"
"Bookmark this page"
"Save page as..."
"Send link"
"View Background Image"
"Select All"
"View Page Source"
"View Page info"
No inspect element :(
Weird, well perhaps I am wrong.
Open a chrome browser and press Ctrl+Shift+I.
Then go to console tab and paste your code and hit enter, that should do it.
Open a chrome browser and press Ctrl+Shift+I.
I don't have Chrome, though.
Web Developer Console is good enough for me...
However, sometimes it gives wierd, undetailed errors, for instance: "too much recursion"
It workcs for firefox, you just need to install a firebug, it's an addon. A developer should always have chrome, firefox and ie :)
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.