javascript / internet explorer 8 crazyness - javascript

I have a web page with javascript in it, everywhere it runs fine except ie8. When I load on IE8 my javascript is missing, so I turn on the developer tools and javascript console to debug it, refresh, and my javascript loads. It seems it only loads when I have previously enabled the JavaScript console.
Can anybody shed some light on this? You can view the page here
http://www.orchestra-agency.com/contentviewer_beta.php?cv=ORC_TWL_01&p=0

Does the page make any console calls, like console.log('foo'), without first making sure that console and console.log are defined?
A simple workaround: log() – A lightweight wrapper for console.log
More powerful version: JavaScript Debug: A simple wrapper for console.log

Does it work in FF without Firebug enabled? If not, I'd bet it's the console.log's that cause it.

Try loading this on the page header
<script type="text/javascript">
// IE fix
if(!window.console) {
var console = {
log : function(){},
warn : function(){},
error : function(){},
time : function(){},
timeEnd : function(){}
}
}
</script>
It removes the functionality of any console code you have. If it fixes the problem, you have to find and clean all of them from your code...
This happens when the browser tries to output to the console but it doesn't exist so it throws an exception and blocks all further javascript.... :S

Related

IE 11 showing error when i clicking with jquery function

IE so much confusing me with some errors like this,
SCRIPT1002: Syntax error
File: jquery-2.1.4.min.js, Line:2 Column 2538
The weird thing is , on firefox and chrome running well and no error.
And some button with jquery click function is working.
I'm Using IE 11
Before this i'm using jquery-1.1.13.min.js and when i use jquery 2.0 it still running properly on firefox and chrome
I'm really new with cross browser so any info will helping me very much, thanks :)
For the record I had this error which only showed itself on IE when doing cross-browser testing of a big Javascript code change.
In my case the problem was a function definition which included what would be a default in any other language:
i.e. Function Foo(param1, param2, param3=false)
.. clearly this was a stupid bit of code .. but it took me a while to track down so this might help someone out there. Doesn't show up in Chrome, FF, or even Edge.
Mostly these errors are not problems of jQuery itself. The problem situates in code using jQuery or inserted into jQuery (callbacks or event functionalities). In my case I used $.ajax to load a remote page in a div element. In the page I loaded there where // comment tags in the javascript part. As IE is putting this content on one line, more code that as I wanted was commented and this created the error.
So if in our case us are using $.ajax maybe this can be an issue. Otherwise best thing to do is debugging the code that generates this error and look for code that is not supported by IE (the version you use). Look for functions passed trough to jQuery.

Can't debug greasemonkey script using firebug or firefox debugger

I found two posts on this but still doesn't seem to be working. I don't see the user.js script in the drop down menu on either firebug or the built-in firefox debugger. I'm still just learning coding and couldn't figure out the workaround strategies. Any help would be greatly appreciated.
How to debug Greasemonkey script on Firefox 30?
How to debug Greasemonkey script with the Firebug extension?
Firefox 35.0
The only way I've found to debug greasemonkey scripts is to use the browser console to get clues and then add alerts in my code where I think the problem is... then if the alert doesn't show up I know the problem is earlier in the code. My code usually ends up looking kinda like this pseudo code:
var i = get.value.from.page
alert(i)
do stuff to i
alert(i)
if (i===5){
do this stuff
alert ("i equaled 5")
}
else{
do this stuff instead
alert("i didn't equal 5, it equaled "+i)
}
Yeah, it's messy and time consuming... but it works.

JS assets in a subdomain wont load on ff & ie but chrome is all good

We are building a Saas product and have purchased a bootstrap dashboard, all the JS/CSS assets are loaded though a sobdomain via our CDN.
Works perfectly on chrome but on ie and ff the components do not load properly, on ff I get the following errors:
TypeError: can't access dead object
ReferenceError: event is not defined
A link to a non working example is below (We don't want to give access to our working dashboard for commercial reasons) You can see the error when click on the "dropdown" menu item. As far as I can tell, all the assets are loading correctly.
http://hunchbuzz.com/acme/index.html
Any help would be appreciated.
Well, take your bugs one by one. Did you turn on the JavaScript Debugger when you tested your page in IE? In the F12 developer tools, select Script and then Start Debugging.
First there were a couple of errors in jquery.sparkline.min.js which I ignored for the moment. Then I tried clicking your 'dropdown' link and got this error:
SCRIPT438: Object doesn't support property or method 'preventDefault'
custom.js, line 3 character 1193
The highlighted code is (reformatted for readability):
$('.dropmenu').click( function(){
event.preventDefault();
// ...
});
Do you see the problem? What is event? The code should be:
$('.dropmenu').click( function( event ){
event.preventDefault();
// ...
});
The fact that it worked in any browser at all is probably due to the global event variable that some browsers create for compatibility with very old code.
Now back to the sparkline problems. I see it hitting two errors in jquery.sparkline.min.js, but with the minimized code the problem isn't jumping out at me the way the other one did.
When you're debugging, it would help a lot to load the non-minified versions of jquery.sparkline.js, custom.js, jQuery, etc. Then you'll have readable code to look at in the debugger, which should make it easier to spot these problems.

HTML5 Canvas page hangs in IE9

TimingCharts.com loads in FireFox, Chrome, Safari and Android devices but hangs in IE9. If I hit F12 and click on just about anything within the developer settings, such as debug, Browser mode, Images etc., the page will then load. As long as I leave the browser open the page continues to work fine. If I close the browser and come back in though, I have to go through the f12 process again.
Several users have confirmed they have the same problem. Can someone tell me what I need to do to make this page load correctly?
Hah I know why. I sent a bug report to Microsoft for this in the IE9 beta! They never replied :-(
You have a console.log on your page and that fouls up IE9 unless developer tools are open. This is a really stupid bug, because as soon as you go to investigate with developer tools, the bug disappears!
You can make it always work by wrapping your statement like this:
if (window.console !== undefined && window.console.log !== undefined) {
console.log('some console output');
}
That should let IE9 work again!
Thanks for the direction Simon! After working with your example for a while I settled on...
<head>
<script type="text/javascript">
if (!window.console) console = {log: function() {}};
</script>
</head>
This seems to have fixed the problem. I really appreciate your help.

Firebug showing eval scripts on one line

When loading a JavaScript block via Ajax, the response is returned ok, but when viewing it in the code in Firebug (1.9.1) in the Script tab, it appears without any newlines. It's extremely difficult or impossible to set breakpoints anywhere.
Is there a way to get Firebug to preserve the newlines?
I don't think so, but Chrome's developer tools unobfuscator may do what you want (http://www.sagarganatra.com/2011/06/de-obfuscating-javascript-code-in.html).
However, if you load in your script blocks by adding a script tag to the page and changing its source to point to the relevant script file the eval function isn't used and firebug should display the script with line breaks included.
Found a fix for Chrome.
Simply add the following snippet to where you want to debug:
try{ throw Error() } catch(e) {}
and click the "Pause on all Exceptions" button in the Chrome Scripts console tab. Then simply hit F8 until you reach your try block.
Works like a charm. :)

Categories

Resources