Click events and Google Chrome and Windows 8 - javascript

I am trying to use the following JQuery code:
$("#thing").on("click", function() {
....})
And it doesn't work on Google Chrome in Windows 8, but it works in Firefox on Windows 8 and basically every other OS. Any ideas?

It works, check this: http://jsbin.com/ofuvuh/1 Probably there is some error in the code that ff ignore or maybe it's your browsers fault. Please check the chrome and ie console, probably it can helps

Try:
$("#thing").click(function ()
{
// your code here
});
Which is the same as .on('click', handler). See .click documentation.

Your code snippet looks completely fine. I assume you are using a fairly up to date version of jQuery, so most probably it is nothing to do with jQuery or the browser. I suspect there might be something wrong with the code surrounding your snippet.
As a possible solution:
In Chrome you can bring up the Console, which will tell you if there is any errors in your JavaScript (developers.google.com/chrome-developer-tools/docs/…). Open it up, refresh your page (you might see the error in the Console straight away). Or click that '#thing' and watch out for any possible errors coming up in the Console.

Related

Firebug has stopped showing me javascript source [duplicate]

Why does Firebug say there is No Javascript on this page when there are clearly loads of JavaScript on the page. I even reloaded the page several time to make sure but it still show the same message.
It never used to do that before, but all of a sudden it misbehaves.
Is it because of some configuration issues or because of something else?
As of Firefox version 50, it seems that Firebug will no longer work as Mozilla are migrating to Firefox Devtools. The tab Tools/Web Developer has a 'debugger' option. See this page for a discussion on the migration. Read all the posts dated 19 November for further information.
It seems to me that the option gives less functionality but Firebug per se is never going to be fixed for Firefox 50 and beyond
EDIT 2017 April
This answer is now outdated and I'm not even testing it anymore because I'm no longer using Firebug (a shame, I loved it years ago in a time it was The tool of trade for web developing).
EDIT 2014 November
The original answer is now more than a year outdated due to firebug evolution.
Thanks to #AmadeusDrZaius to keep it on tracks
Answer for outdated firebug versions
For anyone still with this problem after updating Firebug.
Just click Clear Activation List option inside the Firebug menu.
For those who can't find it, note that "Clear Activation List" shows up in the dropdown from the Firebug icon in the toolbar, but not the Tools > Web Developer > Firebug menu.
I guess due to the bug previous hitting your working page it stays listed as "no activate FB for this site please".
I encountered No Javascript on this page after upgrading Firefox to ver 50.0, with Firebug ver 2.0.18. I tried refreshing Firefox, even completely uninstall Firefox and installed again. Nothing works for me.
A couple of hours later, I downgraded Firefox to 49.0.2, and voila, it works right away. I downloaded the old version here.
I tried everything on this list and nothing worked for me except resetting Firefox like so:
https://support.mozilla.org/en-US/kb/reset-firefox-easily-fix-problems
I realize there are already 10 answers to this question, but in my case none of them helped. I'm running Firefox version 39.0 and Firebug version 2.0.11. The only fix is to completely restart Firefox (i.e. not just the tab or instance with the problem).
Perhaps it's due to Firefox's over-usage of memory, or maybe there's a bug in Firebug. I can't speak to that, but what I do know is it didn't work. I killed Firefox, opened the exact same page again with no changes made and now it works. This has happened to me numerous times and a complete restart always fixes it, but that's the only thing that does.
Since Firefox 49.0 and Firebug 2.0.18 the Script panel is broken. This is due to some internal Firefox API changes. And because Firebug is officially discontinued, this unfortunately won't get fixed anymore.
There was also a bug in Firebug 2.0.11 (and below) in combination with Firefox 39.0 causing this problem. This bug is filed as issue 7918.
It happens when the Script panel is enabled and you close Firebug and reopen it.
You can see two related error messages logged to the Browser Console (can be opened via Ctrl+Shift+J or Firebug menu > Developer > Browser Console):
error occurred while processing 'attach: TypeError: docShell is null
Stack: getChildDocShells#resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/devtools/server/actors/webbrowser.js:53:7
...
and
onPacket threw an exception: Error: Server did not specify an actor, dropping packet: {"error":"unknownError","message":"error occurred while processing 'attach: TypeError: docShell is null\nStack: getChildDocShells#resource://gre/modules/commonjs/toolkit/loader.js -> resource://gre/modules/devtools/server/actors/webbrowser.js:53:7
...
Solution:
The only solution until this bug is fixed is to restart Firefox completely.
Similar things have happened to me because I forgot to add the closing tag.
DON'T do this:
<script src="some.url" type="text/javascript">
or
<script src="some.url" type="text/javascript"/>
DO this instead:
<script src="some.url" type="text/javascript"></script>
The same problem just happened to me. I thought that it was a problem in my scripts, but I checked google.com and the problem persisted.
My problem was that I had updated my version of FF and kept the old version of FireBug. When I updated FireBug and everything was solved.
From firefox 49, the fire bug will be built in and it is called fire-bug next. So the fire bug add on won't work properly and no issues will be solved. So you can use firefox inspector. See here for details information
If the problem only shows up on a single page, check that your script folder is referenced from current folder (".") or that's reachable from the server root ("/").
<script src="./scripts/pagescripts.js" type="text/javascript"></script>
may not be the same as
<script src="/scripts/pagescripts.js" type="text/javascript"></script>
As mentioned, sometimes there's a Javascript syntax error that invalidates the whole script. But I have also had this, and simply opening up the page in a new tab or window and refreshing firebug (disable, enable) gets the javascript to show up again.
One time this caught me out was when I published one of my sites and I was checking it out. No Javascript was working, there were no errors in the console and firebug showed no scripts.
It turned out that in that instance, I'd forgotten to allow the site in NoScript - so there really were no scripts being loaded.
Not sure if that's the problem you're facing but it's worth being aware of.
I also got this error when attempting to use Ajax to a different server than the one serving up the page. JavaScript only allows Ajax access to the server that served up the page.
This problem is STILL happening (Aug 2015) with Firefox 39.0.3 and Firebug 2.0.11
For people saying the code is wrong or missing end tags etc. all I did to get all the javascript to reappear in tab was to shut down Firefox and restart it. I didn't change anything. Also that "Clear Activation List" option didn't work (no idea what that means)
I upvoted #Tom_Thomson's answer above, but I am wondering if simply removing and then reinstalling the Firebug add-on might not have accomplished the same thing without losing all the other stuff like bookmarks.
FWIW this problem is still happening in August 2016. I'm using Firebug 2.0.17 with Firefox Dev Edition 50.0a2.
As a workaround, I'm able to use the Developer Tools, though they are not as robust as Firebug (when it's working).
Well Firefox native Inspector is good... I know that you will miss some things, but in general we can survive with it. The good news is... less one addon, FF will be faster :)

alert() and console.log() not working in Firefox 26

I feel like I'm going crazy but alert() and console.log() refuses to work anywhere on Firefox 26.
At first I thought it was my own website's problem, but I cannot for the life of me to get it to work via javascript: urls, Firebug, I even tried it in jsfiddle.net by just putting alert('test'); in the script panel.
Tried uninstalling and installing again, no luck.
The only extension I'm running is Firebug.
Heck, Stackoverflow didn't even prompt me about leaving when I accidentally clicked the back button while writing this.
Also yes, I made sure there was some content inside the alert() and console.log()
What I mean by not working is that Firefox treats the code as if it were non-existent, nothing happens.
Once again, here's my environment:
Browser: Firefox 26.0
OS: Windows 8.1 Pro
Issue: alert(), console.log(), and apparently prompt() doesn't work
If anyone might know why this is happening, I would highly appreciate an answer.
UPDATE
Following Pointy's comment, it appears that both alert() and console.log() work as expected on the New Tab Page, but nowhere else
You might want to try re-installing Firebug:
console.log in firefox is not working?
PS:
I happen to be running a similar configuration (including FF 26) ... and things work fine for me. IMHO...
PPS:
You might also try setting "about:config, prompts.tab_modal.enabled = false":
https://bugzilla.mozilla.org/show_bug.cgi?id=613752
The default is "true", my FF 26 is set "true" and things are working for me ... but who knows. If reinstalling Firebug doesn't help, maybe it's worth a shot?
Silly but, in firebug can you check if window.alert and window.console are defined.... and if yes then, can you check if window.alert('hi') works ?
Thanks for all the help guys, in the end I used Revo Uninstaller to completely and absolutely wipe Firefox from my system, then installed it again. Seems to be working now, the original uninstaller most likely didn't remove whatever was causing the problem.
I have same bug when i using Ghostery extension. Disable Ghostery and reload page. Lets check at https://getfirebug.com/tests/head/console/api/log.html
I had a similar issue, on IE v11.0.10 and Chrome Canary v38.0.2114. Duplicate function name turnout to be the issue. Worth doing a quick check for function names in Javascript file.
You can use the Firefox console with CTRL + SHIFT + K
Related: https://support.mozilla.org/en-US/questions/876916

Binding handlers to events in IE

I'm trying to bind some functions to an event.
The following code works perfectly fine in Chrome and FF but what's the corresponding code for IE?
$this.mouseenter(function(){
console.log("inside the mouse enter handler");
});
I tried this but it didn't work in IE:
$this.bind('mouseenter', function(){
console.log("inside the mouse enter handler");
});
I need it to work in at least IE 9.
console.log or at least console will give you an error on IE... hence, your javascript will not work... try using alert...
Unable to understand what is wrong # your end.
I tried this and its working fine for me.
console.log will return a js error, if your browser's console is not open. It will happen in any browser, not only with IE. Probably you tried FF and chrome with the browser console open and IE without opening the browser console. Try opening the browser console open in IE as well / by using alert() to test your funcitonality / by directly writing the functionality that you need.
Hope it helps!!!

Javascript and jquery work with IE

My html page cannot work in IE browser. If I turn F12 developer tools on, it starts to work. My page can work with chrome. I guess it is caused by jquery and javascript. Can anyone know how to make it work? Thanks
IE crashes your script if you're using console.log anywhere inside it. Developer tools adds the console functionality - therefor it works if you open it. Remove the console.log and it should start working just fine.
Chrome/Firefox support this by default, thats why it works there no problem.
you're probably using console.log() in your code somewhere. In IE console object doesn't exist unless the dev tools window is active.

How to run JQuery code in IE 8 Script Debugger?

I am trying to use the IE 8's script debugger to run some JQuery code in the Console Tab, but all I get back is
{...}
For example if I try and do something simple like select an element using a class name, I get back some braces an ellipse.
>>$('.someclass')
{...}
I usually use Firefox with Firebug, but I need to use IE's tool in this case since the problem is only with IE. In Firebug you can run script statements with no problem, I figured IE 8 would be the same.
FireBug Lite. The bookmarklet works fine.
http://getfirebug.com/firebuglite

Categories