I want to disable Javascript once a page has already loaded.
Why?
Because I want to test how the behavior of something like the following 'degrades' when javascript isn't available, but i dont want the hastle of going to the browser's top level Javascript enable/disable feature. In addition I specifically want to disable it after the page has loaded because I want to isolate my testing to how that one form would perform (I have jQuery running for the rest of the page and I don't want to lose that).
Allowing me to disable JS for this code allows me to test the form postback as well as the AJAX postback.
<form
action="/pseudovirtualdirectoryfortesting/company/Contact"
id="fooForm" method="post"
onsubmit="Sys.Mvc.AsyncForm.handleSubmit(this, new Sys.UI.DomEvent(event), {
insertionMode:
Sys.Mvc.InsertionMode.replace,
loadingElementId: 'submitting',
onBegin: Function.createDelegate(this,
submitComments_begin), onComplete:
Function.createDelegate(this,
submitComments_complete), onFailure:
Function.createDelegate(this,
submitComments_failure), onSuccess:
Function.createDelegate(this,
submitComments_success) });">
What plug-ins or tactics could I use. I want to be able to test in different browsers, and some projects I work on are designed only for one browser (not my fault) so I need as many possible solutions as there are.
Get the Web Developer Toolbar for Firefox. With it you can disable Javascript at any time, disable cookies, css, whatever you want.
Test in FireFox with the NoScript addon.
I've decided to write a separate answer on this question because I find this topic actually very important. And apparently my comment above hasn't been noticed.
In the past, functionality described:
"disable javascript after browser has rendered the content",
was easily accessible in Opera.
But independent Opera now is dead (now it's Chrome). And apparently there is almost no independent browser at all (google is the default search engine, and often you cannot replace it with your own search engine - duckduckgo would be probably much better alternative).
Well, one can consider that as just an opinion. But, well, It's pretty clear that dynamic-JS-toggle was removed from all major browser for a reason.
I've tried many popular browsers and there is no single one that provides such functionality.
Currently the only up-to-date solution is using surf browser and patch it a bit. Which is to change 1 into 0 in line:
setparameter(c, 1, (ParamName)a->i, &curconfig[a->i].val);
Surf (about, sources, patches):
https://surf.suckless.org/
This is not answer to the generic question "how to disable javascript", but was a good solution for me.
I have stopped using Microsoft's AJAX in place of jQuery.
As a result of this I am using unobtrusive javascript and it is therefore much easier to disable just the AJAX handler for my form than it is with Microsoft Ajax.
All i do is comment out the line that hooks up the AJAX call to my submit button.
Related
In a browser you can determine what files are loaded when a website loads and you can even view the timeline.
But is there any way to determine what javascript calls are being made once the script loads for a website?(in firefox or chrome or any software package)
Hope you got my question
(Because that would be useful for debugging logical javascript errors and others I suppose)
I use Chrome's Developer Tools for this:
Check the click box, and then click on the element on the page you want to find the handler for. If you are using jQuery (or similar library), you may have to step through their code before you get to yours.
Taken from: How do I find out what javascript function is being called by an object's onclick event?
Typically I just use logging in FireBug personally (which despite my desperate approach to avoid Chrome, is turning out to force me to adopt it with built-in developer tools).
Is there any possibility to set the Internet Explorer settings by running Javascript file..?
I want to set the following settings in IE through javascript/Jquery
Go to, ‘Tools’ -> ’Internet options’.
Under ‘General’ tab, click the ‘Settings’ button in the ‘Browsing History’ section.
Choose the radio button "Every time I visit the webpage".
Click ‘OK’ and restart the IE.
This is not possible - it'd be a bit of a security hole if sites were able to do this...
Firstly, the short answer is no: You can't do what you're asking for.
Javascript within the browser is heavily restricted to only being able to access resources for the actual page being viewed. This is an important security feature.
You cannot access other pages or other tabs. You cannot access parts of the browser UI outside of the page itself. You cannot run external programs.
Even if you could, the way you've described it wouldn't work anyway: The settings page you've described is specific to one particular version of IE. So your hypothetical program wouldn't work in any other browser or even any other version of IE.
However, more importantly, you need to ask yourself why you're asking for this.
The thing is that you're trying to solve a problem with your site. You've found something that resolves it, and you've asked a question about how to automate that. But you need to work backward a bit -- stop trying to work out how to automate this particular solution: you need to ask yourself whether there might be a different way of solving the original problem, which could be automated.
The fact is this: the config setting you're trying to change is for handling how the browser deals with caching of files. There are ways of changing the behaviour of caching that can be scripted by your site. You might want to look at questions like this one for example.
The lesson here is this: Don't simply ask how to do something; explain why you're trying to do it as well. There might be an alternative solution that's better than the one you've thought of.
No, it's not possible to do using JavaScript.
This is not what Javascript designed to do. There is only a way to read browser setting from JS - using signed scripts.
This is kind of a two-part question.
Why does IE require so much special treatment when handling Javascript? And are there any tricks, resources, and/or systems you have picked up for making your js IE-compatible, besides Firebug lite?
Using standardised libraries like J-query so you don't have to jump through all the hoops yourself works on the javascript side!
Also Yahoo User Interface (YUI) is good for making websites look extremely similar over different browsers. Their Grids library works really well.
Could you please elaborate little what you're referring to?
JavaScript in it's core is have mainly been the same the last 10 years. If you're worried about older IE versions (IE6-7) you can remain calm. IE6 was released with JavaScript 1.5 support so all JS code should run fine. Mozilla has a very good JS ref document at their MDC site. At the bottom of each page there's usually a list of what version of each browser that supports that specific function.
However the difference between browser usually lies in the DOM implementation or event handling. Where properties may have different names, at the top of my head these properties mainly are related to element/scroll positions.
To find the correct property to use, check in the developer tool (Firebug in IE, Developer Tools in Webkit or Developer Toolbar in IE) for that browser to find what you are looking for. If you're unsure set at JavaScript breakpoint in your code using the debugger;keyword or send something to the console using console.log(). In IE Developer Toolbar is available from IE8+ (I think).
Most of these problems are already resolved in the major JavaScript frameworks like jQuery, MonoTools and so on.
The two main "special treatment" things that come to mind are:
Events. Including assignment of event handlers, the way the event object is made available to the handler function, and some of the properties of the event object. See this page for more info: http://www.quirksmode.org/js/introevents.html
Ajax. Use of XMLHttpRequest versus ActiveXObject("Microsoft.XMLHTTP").
Most everything else should be fine.
You can write yourself some (relatively) simple helper functions to get around these issues, or use a library like jQuery that normalises the differences for you. If you do write it yourself, be sure to test for feature support rather than try to test for which browser - see this (long) article for an explanation: http://jibbering.com/faq/notes/detect-browser/ (I'm sure there are shorter explanations around but I can't be bothered finding one.)
If you using jquery in your page then you can check for ie with this code
if ($.browser.msie && $.browser.version == '6.0') {
//do IE specific code
}
This code will only run when the user browser will be IE 6.0 or you leave this condition
It just seems like something that would be really useful when developing server-side code. If you know that the browser won't be using javascript from the server-side, you could easily accommodate the user. Or if you just felt like it, redirect them to a page that says 'hey... we need you to use javascript for our application' etc.
Does anyone know why this is?
See the <noscript> tag, here.
I know it's probably not ideal (I don't have enough experience with it to pick it apart) but it certainly gives us enough flexibility to degrade somewhat gracefully.
As handy as it would be to have your server be aware of your browser's Javascript capability before page rendering began, I can see a strange edge case such as:
// hide malicious code from people without javascript
if ($header['javascript'] == 'false') {
show_regular_safe_website();
} else {
use_some_nasty_javascript_exploit();
}
One way I use is to have a landing page/login page. When the user presses the logon button then use javascript to submit the results or update a hidden field before posting the logon. If javascript is disabled then the javascript will not work and therefore you can assume they have it turned off.
The real reason is that when Netscape came out with JavaScript, they never thought to make the information available in the HTTP headers. Instead they created the <noscript> tag.
I suppose the Accept field could be used to such a purpose, like "Accept: text/javascript". But since it's proprietary the IETF would never include it in any standards and widespread adaptation is therefore unlikely. Web-developers has coped so far.
Just some short Q regarding javascript and websites.
1- By javascript enabled, does it mean to have 'sun java' installed and enabled in the browser settings? Or does every browser have javascript enabled always?
2- If javascript is disabled, my website for example wouldn't work at all, so what does major developers do in these situations, if the only way to achieve their goal is to use javascript?
3- Is ajax also disabled if javascript is disabled? Also, same for Jquery because its a javascript library ?
Thanks guys
Sun's Java is not the same thing as JavaScript. Java is an extension to the browser which user might or not have installed. JavaScript comes with browser and can be disabled by the user.
Display a notice to the user that he/she should turn JavaScript on.
Ajax and jQuery are Javascript, so yes, they're disabled also.
Question 1: Java and JavaScript are two different languages. JavaScript is a dynamically typed language where Java is strictly typed language (i.e. you have to define variables as int, string, etc...). Every browser except for screen readers should have JavaScript turned on by default. The thing to remember is that users have the ability to turn off JavaScript if they so choose. The reason they turn it off is because during the 90s JavaScript was used in the wrong ways such as creating pop-up after pop-up windows and other mischievous things.
Question 2: You should always develop your website to work without JavaScript turned on. JavaScript is like icing on the cake. It is the fancy behavior that your website has. The technique of developing your website to work with JavaScript turned off but be more "enhanced" when it is turned on is called "Unobtrusive JavaScript". Basically, it means that your users can get to your web pages content without the need of JavaScript. Search in Google for "Unobtrusive JavaScript" and you will find a plethora of information and techniques.
Here are just a couple links to get you started:
A List Apart Behavioral Separation
Easy as Pie - Unobtrusive JavaScript
Question 3: Yes. If JavaScript is turned off then your Ajax methods and jQuery library will not work.
Do some research regarding this topic. You will find a lot of information that will help you in your journey of discovering Unobtrusive JavaScript.
Users can enable or disable javascript in their browser settings. It isn't a matter of what is installed in the browser, but rather the user's preferences.
When you can't use javascript, you generally can accomplish the same thing by doing more postbacks. The user experience will definitely be slower.
Ajax and jQuery rely on javascript being enabled by the user.
No. Javascript and Java are two different thing
Which is why your developers must consider the case where Javascript is disabled. Your site should run gracefully ( albelt with reduce functionality) even if Javascript is not enabled ( such as when on mobile). This means that your should have a basic version of the site for the user without Javascript to browse.
Yes.
All modern browsers come with a built-in JavaScript engine but the user can disable it. JavaScript has a similar syntax as Java (from Sun) but it's a language of its own.
If your website needs JS, then add an HTML element which says "Please enable JavaScript" and make it invisible in one of your scripts. When the users can see it, then she has JS disabled.
AJAX doesn't work when JS is disabled. The same is true for jQuery.
1 - No, javascript is read through web browsers, and is by default on most of the time. A user would normally need to disable it themselves.
2 - There is a development practice called Graceful Degredation which may help you to create websites that will still work if javascript is disabled.
3 - Ajax is much more difficult without javascript, but again Graceful Degredation may help you here.
No. 'sun java' and JavaScript are two different things. JavaScript is present and enabled by default in all modern browsers.
You can place message asking user to enable JavaScript in his browser inside <noscript></noscript> tag.
Yes AJAX and jQuery require JavaScript to be enabled.
Graceful degredation for point 2 is definitely the way to go - jQuery is big on this. Your page contains the markup required for your site to function via postbacks.
This can then be 'hijaxed' by your script to enable AJAX updates etc. This means that if a user is prepared to enable a nicer experience they can.
If you are programming internal intranet sites, you can usually assume that scripting would be enabled - these sites are often very script intensive...
1- Every browse live alone... and so doesnt matter if java is installed for command javascript.
3- AJAX core is javascript. If javascript is disabled, ajax is disabled.