![]() |
If no javascript??
Say I have a link that looks like this:
<a href="javascript:;" onclick="dosomething()">How can I have it default to a normal href if javascript is disabled? I know it's probably a stupid question but I'm really javascript dumb... I want it to link to a normal page.php if the javascript is disabled in the remote browser. -m |
Oy, I'm an idiot. Nevermind, it's just been ten years since I've used <noscript>. -m
|
My apologies for resurrecting this thread, but I think it brings up some important discussion points. Delete it, however, if you wish.
I would use something like the following in lieu of the <noscript> tag:javascript Code:
I have never actually used the <noscript> tag, I must admit. |
No problem, I just took it down to quell the signal to noise ratio.
How does that work? I tried adding it to the head of a page wrapped in <script type="text/javascript"> and added a link with the ID myLink, but nothing, so I'm sure I'm missing something obvious. :P -m |
Javascript shouldn't need <noscript>...
|
No, javascript itself shouldn't, but what about people browsing without javascript? For whatever reason, they have an obscure browser that doesn't support it, or they have it turned off, or...
I've been to a lot of sites, and I'm sure most of you have been too, that break horribly without javascript being enabled. There is absolutely no graceful degradation, you either have it on, or you don't use that site. I've seen some where it breaks something so obviously necessary as the ability to log in, and others where it breaks little things, that chances are the site was better off without anyways. I like AJAX, I think it's nifty, and can be enormously handy in some cases. But anything I use javascript for, I want to make sure there's something in place to handle the situation if there is no javascript. -m |
put the script after the element definition, i.e. before the closing body tag, otherwise it wont exist to it.
|
1 Attachment(s)
My code would only be executed if the end user has JavaScript enabled. If there is no JavaScript then they would simply see the HTML version. Take my little example, if you have JavaScript enabled then the link will take you to Google upon confirmation. If not it will degrade nicely and take you straight to Google without a prompt.
Edit: Or of course I could just return true upon confirmation. Either way. |
That's the most stupid method you could use. The right way:
Code:
<a href="destination-page.html" onclick="dosomething(); return false;">some link</a> |
Quote:
|
I'm 12. And who are you referring to, regarding the most stupid method xenon? Moi? It may be, I won't disagree with that. As I've stated I'm javascript stupid. I could, and probably should go and do at least some basic tutorials to get my feet wet with it again, but I've got so much on my plate that I'm avoiding that for right now. Not a good excuse, but a valid one. Thank you everybody for the help here. -m EDIT: seriously, vBulletin is removing all my line breaks and just being odd right now.
|
I was referring to the <noscript> method. Wildhoney posted a similar solution, but he did that while I was still writing my post :-P
|
I happen to like the noscript method. It makes things complicated and highly obfuscated, which is my silent outcry against usability twits like Jakob Nielsen and Jukka Korpela who think everything on the web needs to be ONE way or no way at all. *runs str_shuffle on all his html*
-m |
well to say <noscript> is stupid is alittle strong, but it is entirly unnecessary as javascript should only act as an enhancement to the current functionality of the site, therefore if javascript is disabled the site will still work without the need for noscript.
|
In my oppinion Javascript comes straight from hell, it introduces nothing but complication and security breachs. Plus, you take the risk of haveing a piece of Javascript that runs perfectly on IE but breaks on FF or Opera og whatever.. Which i find rather sucky! :|
|
Spyke, you don't NEED to use Javascript. Security breaches and cross-browser incompatibilities come from the developer not understanding correctly Javascript or misusing it. So, you can stop blaming something you know nothing about.
|
I don't use it, but i still don't like that everyone seems to love it, and for the most part people can't use it "right", you can write Javascript in so many ways, and it will still work.. That is what i dislike :)
And i know stuff about Javascript :P |
You can write PHP in so many ways and it will still work. ;)
|
Yes, but what i mean is that Javascript isn't as consequent (spelling xD) as PHP.
Fx. in PHP you have to end most lines with a semicolon you don't HAVE to in Javascript, but you can? What is that all about :P |
You should be using a framework such as mootools to get rid of the many cross browser issues. MooTools "normalizes" alot of standard methods that some browsers may not have or is named differently.
But its also limited what I've run into with cross browser javascript issues even on more advanced tasks, the only potential thing I find is the Mozilla's .textContent vs. the .innerText one. Ofcourse you can say like: var text = (element.textContent || element.innerText); |
| All times are GMT. The time now is 08:50 PM. |
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0