Alternate for document-start in Opera browser - javascript

I have seen "#run-at document-start" and "contentScriptWhen: 'start' " in Firefox extension(or userscript).
All these statements are used to run some scripts, while the web page starts loading in Firefox.
Now I want to run my script at document start in Opera extension (or userscript).
How to catch this start event in Opera browser?

What you want is actually the default behaviour of opera user javascript.
Gotcha #1: your script must have .js extension, and not .user.js
Gotcha #2: when you use .js userscript you have to manually listen for loading events.
But, imho the price for the power you get - is not that high ;)

Related

How to programatically change the about:config dom.max_script_run_time value in Firefox?

I am just wondering if there is any way to programatically change the dom.max_script_run_time value in the Firefox about:config window.
When the default values in my Firefox is 10, I think its too less to run a script running for longer time in my website. On when the value is set to default(i.e.10) my firefox goes Not Responding and I get warning alert message like Warning: Unresponsive Script I just need to set the value to 20 or 30 to avoid any such alerts popping often and let the script to run for longer time.
So I just need to change the dom.max_script_run_time each time the page gets loaded.
I have tested this in other browsers like Firefox, Chrome, Safari, Palemoon and Opera..
I have this problem only in Firefox
Or is there any other way rather than changing the settings and loading the page?
Any solution will be appreciated.
definitely, you can't change that value via web. I'm 100% sure
you should try to redesign your scripts and make your pages lighter
for example you should avoid, sadly, on firefox, as best you can
border-radius
box-shadow
text-shadow
dynamic gradients like -moz-linear-gradient -moz-radial-gradient etc
transitions/animations and transforms
frequent text rendering and re-rendering
huge backgrounds especially with background-attachment:fixed
flash objects, canvas, svg
Anyway I found another solution to solve this problem. And thats Defered loading of JS concept from page speed insights. Got the help from here..I have added the code below to load the javascript file asynchronously after the page is loaded. This stops displaying the non responsive script warning in Firefox.
Now all my javascript functions stored in the someScript.js is called just after the page stops loading and with a small time elapsed in between. But thats not a problem as far as I don't get the unresponsive script error.
Deferred Loading of JS:
<script type="text/javascript">
// Add a script element as a child of the body
function downloadJSAtOnload() {
var element = document.createElement("script");
element.src = "/js/someScript.js";
document.body.appendChild(element);
}
// Check for browser support of event handling capability
if (window.addEventListener)
window.addEventListener("load", downloadJSAtOnload, false);
else if (window.attachEvent)
window.attachEvent("onload", downloadJSAtOnload);
else
window.onload = downloadJSAtOnload;
</script>
Set integer to 1000 or 0 at about:config dom.max.script_run_time.
I have found this to be a reliable fix and Firefox no longer has the
Warning: Unresponsive Script error message, runs alot faster and is an
immediate fix.

How to debug the javascript in asp.net?

I want to know ,how to debug javascript in asp.net?Can I apply break point to javascipt?
You could do following
Use debugger keyword with .Net IDE. In your javascript on your page.
something like this.
Use F12 Developer tool with IE browser.
Use FireBug with Firefox.
Use Control - Shift - J to open Developer Tools and bring focus to the Console. for Google Chrome.
If you are using Visual Studio along with Internet explorer, you can debug javascript by simply applying breakpoints. Or else if you want to debug your javascript file in fire fox or chrome browsers you can make use of tools like Firebug # http://getfirebug.com/
You can use firefox firebug or chrome tool.
for example:
you click in chrome examine the element and then in "Source" you select your script add breakpoints and debug it.
You can use Firefox but Firebug should be installed. Then, from Script tab, you should "Reload" to see all resources. After that, when you want to debug any line, put breakpoint to left side of code and when you reload the page debug will start and you can step into/ over / out, continue, rerun..
You can use Firebug tool in Mozilla browser it will notify all the error in your javascript, what java scripts are loaded, function call to javascripts are correct or not on run time.

Javascript-oriented Firebug plugin?

Does anyone know of a browser plugin (Ch or FF) or perhaps a Firebug plugin, which would show me all attached event javascript handlers to currently selected DOM element? I have to debug one site that I received to take care of, with lots of spaghetti-style javascript.
For Chrome, I guess the normal dev tool would do: http://screencast.com/t/KHKeMIj6BiDk (this is a Safari actually, but this should come with other webkit desktop browers as well)
In the meanwhile, read this stackoverflow question: How to find event listeners on a DOM node when debugging or from the JavaScript code?

Javascript bookmark stopped working in Firefox 13

In Firefox version 13, bookmarklets (bookmarks with a javascript: URL, e.g. javascript: alert("it works") stopped working. Is there any solution to use javascript: bookmarks in Firefox 13?
This is a consequence of Bug 728313 - Using a bookmark keyword to a bookmarklet fails on new tabs, also Bug 739387 - Aurora 13a New Tab display doesn't allow javascript bookmarks to be selected . This bug affects Firefox 13 onwards.
As a consequence of the fix to bug 723808, javascript: bookmarks are disabled in a just-created new tab. If you first load almost any URL, including about:blank, then a Javascript bookmark will work in that tab.
Note that this is about Javascript bookmarks (bookmarklets). You cannot use this workaround to load javascript: URLs typed directly in the location bar. These have been disabled since Firefox 6, as a consequence of bug 656433 (phishing of javascript: URLs). Bug 680302 is a feature request to allow turning javascript: URLs back on through a preference. Valadrem has written the InheritPrincipal extension to remove this restriction (I haven't tested it). You can still type and run Javascript code in the Scratchpad (press Shift+F4, type code, press Ctrl+R).
There are restrictions on the Javascript you can run from the URL bar or from a bookmark. For example, since Firefox 7, you cannot resize the window (consequence of the fix to bug 565541); the services.sync.prefs.sync.dom.disable_window_move_resize controls this restriction.
NOTE: this solution no longer appears to work as of FF41. See JS Bookmarklets stopped working in Firefox 41.
If you first load almost any URL, including about:blank, then a
Javascript bookmark will work in that tab.
Since Firefox's default behavior for new tabs is about:newtab, which is nothing, and bookmarklets only run once something is loaded, you can do the following to set a default page, and then run bookmarklets:
open about:config
find browser.newtab.url
double-click and change from about:newtab to about:blank (or URI of your choice)
Ctrl-T and run bookmarklets in new tabs!
I have been able to use bookmarklets in recent versions of firefox (I just tested a few on FF23). Two suggestions:
Replace spaces with %20. For instance, try your example bookmarklet code with javascript:alert("it%20works") instead of javascript:alert("it works")
If this isn't enough, enclose the whole bookmarklet inside an anonymous function, so in your example, you'd write javascript:((function(){alert("it%20works");})())

Running JS whenever a specific page is loaded

I currently have a bookmarklet that I want to be executed whenever a specific page is loaded.
Is there a Chrome extension or similar that will let me do this?
You can do this with Chrome user scripts. In Chrome, you use a #match line like:
// #match http://www.google.com/*
to specify the page.
These are similar to Greasemonkey scripts, with some browser-specific differences. See this list of scripts that work in Chrome.

Categories

Resources