Hi there.
I am trying to make a website and was hoping to code it in such a way that it works even when Javascript is disabled. So far it seems to be working except i need to find a way for events such as onclick to work even when Javascript is disabled. Is this possible? I have no working code and have met dead ends everywhere I look.
Any and all suggestions are welcome.
Thanks for your time.
OnClick without javascript
Page 1 of 17 Replies - 2559 Views - Last Post: 06 July 2010 - 02:53 PM
Replies To: OnClick without javascript
#2
Re: OnClick without javascript
Posted 05 July 2010 - 03:17 PM
Unfortunately, this isn't possible - onclick is a javascript-only deal.
#3
Re: OnClick without javascript
Posted 05 July 2010 - 03:37 PM
Ok, thanks girasquid. Is there any other way to replicate onclick style features or is Javascript the only option for click events?
Thanks again.
Thanks again.
#4
Re: OnClick without javascript
Posted 05 July 2010 - 11:09 PM
you could try Java Applets, but they depend on an installed JRE (Java Runtime Environment). If you ask me, stick to Javascript.
#5
Re: OnClick without javascript
Posted 06 July 2010 - 12:24 AM
Actually, if you give us an idea what you are trying to do we can possibly help.
You can't make a javascript event trigger without javascript, obviously, but think about what you're trying to achieve with the onclick and try do see how your page works without it. Unless you're writing something that's basically a JS app, there's no need for any script. The guiding principle here is to make a page and then go over it and make some things cooler if javascript is available.
Form validation can (and should) be done server-side as well as client-side. The window location should be changed with anchors and buttons not with javascript unless it's degradable. Animations should degrade. Sound effects should not exist.
Some effects can also be handled by CSS. For instance, clicking an input field to set its colour can be achieved using the selector input:focus.
Show us what you're trying to do.
You can't make a javascript event trigger without javascript, obviously, but think about what you're trying to achieve with the onclick and try do see how your page works without it. Unless you're writing something that's basically a JS app, there's no need for any script. The guiding principle here is to make a page and then go over it and make some things cooler if javascript is available.
Form validation can (and should) be done server-side as well as client-side. The window location should be changed with anchors and buttons not with javascript unless it's degradable. Animations should degrade. Sound effects should not exist.
Some effects can also be handled by CSS. For instance, clicking an input field to set its colour can be achieved using the selector input:focus.
Show us what you're trying to do.
#6
Re: OnClick without javascript
Posted 06 July 2010 - 01:12 AM
moopet, on 06 July 2010 - 07:24 AM, said:
Some effects can also be handled by CSS. For instance, clicking an input field to set its colour can be achieved using the selector input:focus.
additionally, mouseover (esp. rollover) effects can be done by using the :hover pseudo class (known examples are the "Suckerfish Dropdown" and "Image Sprites")
#7
Re: OnClick without javascript
Posted 06 July 2010 - 02:06 PM
Thanks for the replies, I have tried using some of the CSS suggestions you made and they have helped in some areas.
I am trying to make a form for a website and wanted an area to be either invisible or disabled until you click on a checkbox. When the checkbox is ticked, the area is visible, when it is not it is invisible/disabled. Also I wanted to create a small script that updates a cost area every time a selection is clicked/changed. I got it all working with javascript but would like the form to be accessible to those who don't have javascript turned on. Is this possible or is there any way I could make this type of thing work without javascript, perhaps using CSS or server side. I can use PHP if necessary.
I am trying to make a form for a website and wanted an area to be either invisible or disabled until you click on a checkbox. When the checkbox is ticked, the area is visible, when it is not it is invisible/disabled. Also I wanted to create a small script that updates a cost area every time a selection is clicked/changed. I got it all working with javascript but would like the form to be accessible to those who don't have javascript turned on. Is this possible or is there any way I could make this type of thing work without javascript, perhaps using CSS or server side. I can use PHP if necessary.
#8
Re: OnClick without javascript
Posted 06 July 2010 - 02:53 PM
Ah, ok.
The way forward is pretty straightforward:
Leave the area visible by default, and in javascript make a call to check and hide it iff the checkbox is unchecked as soon as the page loads. Combined with binding to the click event, that'll do it.
For example (using jquery because it's so much easier)
The way forward is pretty straightforward:
Leave the area visible by default, and in javascript make a call to check and hide it iff the checkbox is unchecked as soon as the page loads. Combined with binding to the click event, that'll do it.
For example (using jquery because it's so much easier)
$(document).ready(function() {
if ($('#mycheckbox:checked').length) {
$('#myarea').hide();
}
$('#mycheckbox').change(function() {
if ($('#mycheckbox:checked').length) {
$('#myarea').show();
}
else {
$('#myarea').hide();
}
});
});
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote



|