Hello There, Guest!
View New Posts  |  View Today's Posts
Disabling JavaScript event selectively in Browsers

  • 0 Vote(s) - 0 Average


10-31-2014, 10:47 AM #1
Holmes.Sherlock
Senior Member
***
Posts: 370 Threads:46 Joined: Oct 2011 Reputation: 7

Disabling JavaScript event selectively in Browsers
I was doing an experiment on browsers. It needs to disable OnBlur() event of JavaScript. Can there be any means to selectively enable/disable JS events?

10-31-2014, 03:40 PM #2
Louis
Master of the IRCs!
**
Posts: 153 Threads:23 Joined: May 2012 Reputation: 11

RE: Disabling JavaScript event selectively in Browsers
I don't think it's actually possible. The only method I can think of is selecting all elements that have onblur attached and then overwriting it or maybe nooping onblur for ALL elements.

Code:
[].forEach.call(document.getElementsByTagName("*"),function (elm) {
   elm.onblur = function(e){ e.preventDefault(); }; // Prevent the default onblur actions?
});
This code is untested however.


EDIT: If you want, I could possibly create a small(ish?) lib to disable things similar to this method besides just onblur.
This post was last modified: 10-31-2014, 04:16 PM by Louis.

10-31-2014, 08:15 PM #3
AceInfinity
Developer
*******
Administrators
Posts: 9,733 Threads:1,026 Joined: Jun 2011 Reputation: 76

RE: Disabling JavaScript event selectively in Browsers
I don't think you're in any better hands than to have Louis answering your questions on Javascript lol. cheers


Microsoft MVP .NET Programming - (2012 - Present)
®Crestron DMC-T Certified Automation Programmer

Development Site: aceinfinity.net

 ▲
 ▲ ▲

11-01-2014, 01:27 AM #4
Holmes.Sherlock
Senior Member
***
Posts: 370 Threads:46 Joined: Oct 2011 Reputation: 7

RE: Disabling JavaScript event selectively in Browsers
Can't there be any such plugin which can rewrite site's Javascript code dynamically?

11-01-2014, 02:14 AM #5
Louis
Master of the IRCs!
**
Posts: 153 Threads:23 Joined: May 2012 Reputation: 11

RE: Disabling JavaScript event selectively in Browsers
Yyyeeeaaaa... no. Using code to rewrite code is definitely not the way to go. There is no way to disable pieces of code like that. You can only reset DOM elements and the like. Itd be insanely complicated to edit out parts you dont want as code can change. Better off doing it the way i suggested.




Forum Jump:


Possibly Related Threads...
Thread Author Replies Views Last Post
  Javascript-based Web Game - Untrusted AceInfinity 1 793 09-10-2015, 08:33 AM
Last Post: Mazzn
  Javascript Click iframe src on page load ѕα3єкα 1 1,272 06-17-2014, 06:09 PM
Last Post: AceInfinity
  Javascript problem william7 4 3,455 03-01-2014, 07:21 PM
Last Post: AceInfinity
  Javascript Issue QBcrusher 1 1,193 01-05-2014, 02:37 PM
Last Post: KoBE
  [JavaScript] Favicon Typing Test Louis 2 1,739 12-26-2013, 09:10 PM
Last Post: KoBE


Users browsing this thread: 1 Guest(s)