473,396 Members | 1,990 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

disable js with js

Circular nonsense here but something says to me that it might just be
possible to at least emulate it. Does anyone know of a way to
effectively kill all JavaScript functions by using JavaScript iteself?

All CSS and browsing functionality would need to remain.

Chandy

Apr 7 '06 #1
11 1651


ch****@totalise.co.uk wrote:
Circular nonsense here but something says to me that it might just be
possible to at least emulate it. Does anyone know of a way to
effectively kill all JavaScript functions by using JavaScript iteself?


Well if your script has the rights to do so then with Netscape/Mozilla
calling
navigator.preference('javascript.enabled', false)
disables script. Only script in a HTML document loaded from a HTTP
server does not have the privilege to do so. And script in a HTML
document loaded from the local file system needs to request the
privilege. Script in an extension has the privilege to do such things.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Apr 7 '06 #2
I guess it depends on how loosely you want to define "CSS and browsing"
functionality.

If you don't care if you get rid of javascript enhanced CSS and
browsing functionality, then the following will probably work, although
it's untested and likely not to be completely robust:

First, get all the <script> elements from the page's DOM and remove
them - set there innerHTML to "" and remove their src attributes. Then
go through every other element and remove any event elements (onClick,
onKeyPress, etc.) contained within. Magically all of your javascript
disappears...ideally...

This worked for me...I think.

<html>
<script>
function traverseDomTree() {
var html_element = document.getElementsByTagName("html").item(0);
traverseDomTree_recurse(html_element);
alert("done");
}

function traverseDomTree_recurse(curr_element) {
var my_string = "";

if(curr_element == null) {
return;
}

if(curr_element.nodeName == "SCRIPT") {
curr_element.setAttribute("src", "");
curr_element.innerHTML = "";
return;
} else if(curr_element.nodeName == "#text") {
return;
}

curr_element.setAttribute('onclick', '');

var i;
for(i=0; curr_element.childNodes.item(i); i++) {
traverseDomTree_recurse(curr_element.childNodes.it em(i));
}
}

</script>
<body>

<a href="#" onClick="alert('hello');">Click Here</a>

<br>

<input type="button" onClick="traverseDomTree();">

</body>
</html>

-Jeff

Apr 7 '06 #3
JRS: In article <11**********************@g10g2000cwb.googlegroups .com>
, dated Fri, 7 Apr 2006 08:54:50 remote, seen in
news:comp.lang.javascript, ch****@totalise.co.uk posted :
Circular nonsense here but something says to me that it might just be
possible to at least emulate it. Does anyone know of a way to
effectively kill all JavaScript functions by using JavaScript iteself?

All CSS and browsing functionality would need to remain.


Consider
<input type=button value="Morituri te salutamur" onClick="splat">
which usually does about what you want in at least one browser.

--
© John Stockton, Surrey, UK. ?@merlyn.demon.co.uk Turnpike v4.00 IE 4 ©
<URL:http://www.jibbering.com/faq/> JL/RC: FAQ of news:comp.lang.javascript
<URL:http://www.merlyn.demon.co.uk/js-index.htm> jscr maths, dates, sources.
<URL:http://www.merlyn.demon.co.uk/> TP/BP/Delphi/jscr/&c, FAQ items, links.
Apr 8 '06 #4
> Consider
<input type=button value="Morituri te salutamur" onClick="splat">
which usually does about what you want in at least one browser.

Some would rib one for not quoting all attribute values ("button") or for
not closing the tag (" />") or for misspelling "salutamus" or make some
comment like"until you learn html...yadda yadda" - but not me.

Apr 9 '06 #5
Hal Rosser wrote:
Consider
<input type=button value="Morituri te salutamur" onClick="splat">
which usually does about what you want in at least one browser.
Some would rib one for not quoting all attribute values ("button")


Maybe, but advising people to quote all attribute values is justified
with the suggestion that doing so allows you to operate in ignorance of
the HTML rules about which characters are allowed in an unquoted
attribute and which would require an attribute to be quoted. The word
'button' does not include any characters that fall into the set that
would require quoting of the attribute value.
or for not closing the tag (" />")
Anyone who proposes doing that in an HTML document will be subject to
quite a critical response themselves.
or for misspelling "salutamus" or
Typically, if you attempt to criticise another's spelling on Usenet the
critical post will include at least one spelling mistake of its own ;-)
make some comment like"until you learn html...yadda yadda" -
Learning HTML prior to attempting to script HTML documents has got to be
a good idea. However, that short snippet of HTML is technically
faultless.
but not me.


That is probably for the best.

Richard.
Apr 9 '06 #6
>
but not me.


That is probably for the best.

Richard.


Like I said, Some would criticize - but not me. I wouldn't be that rude.
Apr 9 '06 #7
Hal Rosser wrote:
but not me.


That is probably for the best.

Richard.


Like I said, Some would criticize - but not me. I
wouldn't be that rude.


Criticism, in itself, is not rude. Indeed critical peer review is one of
the most efficient learning tools available. Providing informed
criticism, with justifications/explanations, can be a great service to
the interested student.

Where criticism becomes rude is when there is no hope of learning
anything from the originator of the criticism. I.E. when there is no
explanation or justification of the criticism, and no hope of receiving
such through further interaction with the critic.

Incidentally, you are not attributing the material you are quoting, or
marking the edits in your quotes. Both would be expected in well-formed
Usenet posts.

Richard.
Apr 9 '06 #8
"Richard Cornford" <Ri*****@litotes.demon.co.uk> wrote in message
news:e1*******************@news.demon.co.uk...

Incidentally, you are not attributing the material you are quoting, or
marking the edits in your quotes. Both would be expected in well-formed
Usenet posts.

Richard.


I did not realize they would be expected in a threaded format like this.
Thanks for pointing it out.

Apr 9 '06 #9
"Hal Rosser" <hm******@bellsouth.net> writes:

[attributing quotes]
I did not realize they would be expected in a threaded format like this.
Thanks for pointing it out.


It's an artifact of how usegroups work. Each news server can have its
own rules for retaining older messages. It is quite likely that people
will read a reply to a message after that message is no longer
available from their server. Even if the client wanted to, it couldn't
tell you who wrote the previous message or what it said.

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
'Faith without judgement merely degrades the spirit divine.'
Apr 9 '06 #10
Lasse Reichstein Nielsen wrote:
"Hal Rosser" <hm******@bellsouth.net> writes:
[attributing quotes]
I did not realize they would be expected in a threaded format like this.
Thanks for pointing it out.


It's an artifact of how usegroups work.


No, it is not. (BTW: "usegroups"?) Sure, there is a technical reason for
quoting what you are replying to. However, the more important reason is
the social one of retaining context of the statement, and preventing
potential readers to dig out that references and its authors from all what
was posted before. It is a matter of efficiency, and, last but not least,
simple courtesy towards the potential reader and discussion participant.

Therefore, quoting and providing attribution as a recommended posting style
is not restricted to NetNews messages, although some forms of electronic
discussion, such as bulletin boards on the Web, tend to ignore that.
PointedEars
Apr 9 '06 #11
Lasse Reichstein Nielsen wrote:
"Hal Rosser" <hm******@bellsouth.net> writes:
[attributing quotes]
I did not realize they would be expected in a threaded format like this.
Thanks for pointing it out.


It's an artifact of how usegroups work.


No, it is not. (BTW: "usegroups"?) Sure, there is a technical reason for
quoting what you are replying to. However, the more important reason is
the social one of retaining context of the statement, and preventing
potential readers from diggin out those references and the names of their
authors from all what was posted before. It is a matter of efficiency,
and, last but not least, simple courtesy towards the potential reader and
discussion participant.

Therefore, quoting and providing attribution as a recommended posting style
is not restricted to NetNews messages, although some forms of electronic
discussion, such as bulletin boards on the Web, tend to ignore that.
PointedEars
Apr 9 '06 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Bob Bedford | last post by:
I create checkboxes using datas from a database (with PHP). I store all values in an array, as I must pass this value like a Form value. Now, in some cases, when a checkbox is selected, I must...
6
by: nntp | last post by:
I have a set of links which I want search engines to crawl them, but I want to disable them from my visitors, so I will ask the link owners to pay me to let me enable them. <a disabled...
12
by: Forti2ude | last post by:
Hello, I have a simple form... <form> <select name="foo" multiple> <option value="1">one</option> <option value="2">two</option> <option value="3">three</option> </select>
13
by: Rich | last post by:
Hello, So I would like to disable a textbox on a vb.net form without the text getting grayed out. In vb6 I could place a textbox control on a frame control and disable the frame leaving the...
4
by: Chris | last post by:
I have an asp.net page say page1.aspx. The form in html code is <form id = "Form1"> And i want to disable all the fields of the form after some code steps. I had created a javascript funct: ...
0
by: Ahmad Jalil Qarshi | last post by:
Hi! I have a problem while developing some webpages.The Problem is that:- How We Can Disable The Controls Of One Web Form From Other Web Form In Asp.net? Explanation:- There Should Be Two...
8
by: prado | last post by:
I want to disable a table with javascript. In this table i have 'n' record and each record has 3 buttons. If you click a button does an action. I want to disable the all table. is there any way...
4
by: Phoe6 | last post by:
Hi all, I am trying to disable the NIC card (and other cards) enabled in my machine to test diagnostics on that card. I am trying to disable it programmatic using python. I checked python wmi and...
0
by: sainiranji | last post by:
Hi All I have diffrent categories in diffrrent logging purpose and all are working fine...but now my requirment is to disable all at once . The below are change i did for disable all logges...
8
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - How do I disable the right mouse button? -----------------------------------------------------------------------...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.