| We hope you enjoy your visit. You're currently viewing our forum as a guest. This means you are limited to certain areas of the board and there are some features you can't use. If you join our community, you'll be able to access member-only sections, and use many member-only features such as customizing your profile, sending personal messages, and voting in polls. Registration is simple, fast, and completely free. Join our community! If you're already a member please log in to your account to access all of our features: |
| JavaScript; Little Prob | |
|---|---|
| Tweet Topic Started: May 18 2005, 10:16 AM (381 Views) | |
| JoeC | May 18 2005, 10:16 AM Post #1 |
|
Euch! IE tastes horrible!
![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
I will point out here I know no javascript; I'm trying to blag it. OK, on my site, I want javascript to detect the monitor resolution, and depending on it, take the user somewhere else. I currently have:
Any help would be greatly appreciated. |
![]() |
|
| Das | May 18 2005, 10:50 AM Post #2 |
![]()
Smells of rich mahogany
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
Correct me if I am wrong, but you can only have one else statement, and it is window.location |
![]() |
|
| JoeC | May 18 2005, 10:54 AM Post #3 |
|
Euch! IE tastes horrible!
![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
OK, if that is the case, can someone write me a switch...case statement, or whatever I'd need to use, please? |
![]() |
|
| Rory | May 18 2005, 11:07 AM Post #4 |
|
i;m a mess
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
your if() { } else if { } else if { } else { } should be fine, i know it is with php, not sure about the syntax of JavaScript though. |
![]() |
|
| Stefan | May 18 2005, 11:28 AM Post #5 |
![]()
Mew?
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
It's fine in JavaScript. It's the same syntax as in PHP. But you can't use colons like in PHP. This is JS ifelseifelse :
If your conditional stuff for a condition is one line, you can leave out the curly braces enclosing it. |
![]() |
|
| JoeC | May 18 2005, 12:34 PM Post #6 |
|
Euch! IE tastes horrible!
![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
OK, so now I have:
And it still doesn't work. My mate said to try putting this in the body:
So I've tried with and without it, but still no luck. Any more help? |
![]() |
|
| Stefan | May 18 2005, 01:41 PM Post #7 |
![]()
Mew?
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
If you use
and include detect() (a function has to be called, otherwise the code isn't run), it should work. The way you have it now, browsers will detect "text/javascript" as being the script language. That script language doesn't exist, so it won't be run. type="text/javascript" gives the script the "text/javascript" MIME type, which means as much as "text that should be handled as javascript". And modern browsers know how to handle that. |
![]() |
|
| JoeC | May 18 2005, 01:50 PM Post #8 |
|
Euch! IE tastes horrible!
![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
It works Thanks alot, that's great Stefan ![]() Edit: Oh, and can you lock / delete this now please? Just clutter
|
![]() |
|
| Stefan | May 18 2005, 02:02 PM Post #9 |
![]()
Mew?
![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]() ![]()
|
As you wish
|
![]() |
|
| 1 user reading this topic (1 Guest and 0 Anonymous) | |
| « Previous Topic · Technology Chat · Next Topic » |
| Track Topic · E-mail Topic |
6:22 AM Jul 11
|


![]](../../../../0/1/0/p601690/pipright.png)




Thanks alot, that's great Stefan 
6:22 AM Jul 11