To disable a page

D

Dr J R Stockton

I have a Web javascript page, and if a certain test gives true I would
like to disable the page by executing a javascript function.

By that, I mean that it should remain readable, scrollable, etc., but
the input controls will not have the usual effect. However, suppressing
any means of view source or save as is undesirable; and at least one
obvious way of saving a copy must remain working (cache search does not
count).

There are (currently) 10 buttons, 1 textarea, and 5 input type=text to
suppress.

It would be sufficient to disable all button onClick routines, but it
would be nicer to render the buttons un-depressable or visually non-
working (but readable) and the text inputs also unreceptive.

Maybe a sort of layer over everything, for which all events do nothing?

Suggestions?
 
E

Evertjan.

Dr J R Stockton wrote on 21 okt 2007 in comp.lang.javascript:
I have a Web javascript page, and if a certain test gives true I would
like to disable the page by executing a javascript function.

By that, I mean that it should remain readable, scrollable, etc., but
the input controls will not have the usual effect. However,
suppressing any means of view source or save as is undesirable; and at
least one obvious way of saving a copy must remain working (cache
search does not count).

There are (currently) 10 buttons, 1 textarea, and 5 input type=text to
suppress.

It would be sufficient to disable all button onClick routines, but it
would be nicer to render the buttons un-depressable or visually non-
working (but readable) and the text inputs also unreceptive.

Maybe a sort of layer over everything, for which all events do
nothing?

Suggestions?

<script type='text/javascript'>
var stop = false;
</script>

<form onsubmit='return !stop;'>
<input type=submit>
</form>

<button onclick='stop = true;'>
stop the form from submission
</button>

or

var f = document.forms[0].getElementsByTagName('input');
for (var i=0;i<f.length;i++)
f.disabled='disabled'
 
D

Dr J R Stockton

In comp.lang.javascript message <[email protected]>,
Dr J R Stockton wrote on 21 okt 2007 in comp.lang.javascript:
<script type='text/javascript'>
var stop = false;
</script>

<form onsubmit='return !stop;'>
<input type=submit>
</form>

<button onclick='stop = true;'>
stop the form from submission
</button>

Surely that will only prevent the form being submitted? In this case
(a) It never submits anyway
(b) I want it to *look* dead.
Disabling the form itself has a good visual effect in IE6.
or

var f = document.forms[0].getElementsByTagName('input');
for (var i=0;i<f.length;i++)
f.disabled='disabled'


OK, I think, if the textarea is also disabled. Thanks.
 
E

Evertjan.

Dr J R Stockton wrote on 22 okt 2007 in comp.lang.javascript:
var f = document.forms[0].getElementsByTagName('input');
for (var i=0;i<f.length;i++)
f.disabled='disabled'


OK, I think, if the textarea is also disabled. Thanks.


var f = document.forms[0].getElementsByTagName('input');
for (var i=0;i<f.length;i++)
f.disabled='disabled'
var f = document.forms[0].getElementsByTagName('textarea');
for (var i=0;i<f.length;i++)
f.disabled='disabled'
 
D

Dr J R Stockton

In comp.lang.javascript message <[email protected]>
Dr J R Stockton wrote on 22 okt 2007 in comp.lang.javascript:
var f = document.forms[0].getElementsByTagName('input');
for (var i=0;i<f.length;i++)
f.disabled='disabled'


OK, I think, if the textarea is also disabled. Thanks.


var f = document.forms[0].getElementsByTagName('input');
for (var i=0;i<f.length;i++)
f.disabled='disabled'
var f = document.forms[0].getElementsByTagName('textarea');
for (var i=0;i<f.length;i++)
f.disabled='disabled'


You're assuming that it's the first form (which it is; it's also the
last). I can simplify the above a little, as there is already a
reference to the form and the name of its textarea is known.

+ + +

General : some time ago, there was a discussion in CLJ about converting
a Number (IEEE Double) to a row of bits and /vice versa/. I did that,
with conversion also to/from Single. This is to say that the code, in
<URL:http://www.merlyn.demon.co.uk/js-misc0.htm>, now deals correctly
with the sign of zero, NaN, +-Infinity, and I think with Denormals.

It also provides the exact value - for example,
0.06+0.01 -> +0.06999999999999999278355033993648248724639415740966796875
0.07 -> +0.070000000000000006661338147750939242541790008544921875
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,152
Latest member
LorettaGur
Top