Skip to content Skip to sidebar Skip to footer

I Add 10 Functions To A Code, I Don't Even Call Any Of Them, But The Code Stops Working!

Alone, this code works: CustomButton = { 1: function () { alert('Just testing') }, } I add the code below and the code above stops working: function getvisitingnow() {

Solution 1:

try adding your functions one by one. see at which function your code stops working. then empty the function contents only to put it back with pieces at a time. check again where your code stops working. about there should be a syntax error.

But as Bobby suggests, the easier way is to try Firefox Errorlog, or maybe Firebug.

Solution 2:

One little JavaScript-error can break a lot of things. You have forgotten to add semicolons in two places.

There needs to be a semicolon after sitefound[0] here:

function regexforsitefound(uri, searchcontents) {
    var re = new RegExp("\\<div class=g\\>.*?(?:\\<a href=\\\"?(.*?)\\\"?\\>.*?    ){2}\\</div\\>", "mi");
    var sitefound = searchcontents.match(re);
    if (sitefound[0]) return sitefound[0] elsereturn null; 
}

and one after categoryfound[1] here:

function regexforcategoryfound(uri, searchcontents) {
    var re = new RegExp("\\<div class=g\\>.*?(?:\\<a href=\\\"?(.*?)\\\"?\\>.*?){2}\\</div\\>", "mi");
    var categoryfound = searchcontents.match(re);
    if (categoryfound[1]) return categoryfound[1] elsereturn null;
}

Solution 3:

if (sitefound[0]) return sitefound[0] elsereturnnull;

This syntax is invalid.

Try:

if (sitefound[0])
    return sitefound[0];
elsereturnnull;

Solution 4:

If you are a Mac user, open (a recent version) of Safari and hit

⌥⌘ + i,

which opens up a great panel with lots of charts and data about the client-server interaction. You can also see and locate javascript errors, or debug javascript in a console directly. neat.

For Firefox, try the excellent firebug to see, what went wrong where .. in their own words: [with Firebug] .. you can edit, debug, and monitor CSS, HTML, and JavaScript live in any web page.

Solution 5:

The comma after the function in CustomButton can break code the code in IE. Also, if you are using CustomButton the first time here, you should introduce it with var. I know these are not the issues you asked for, but otherwise, everything seems correct.

Post a Comment for "I Add 10 Functions To A Code, I Don't Even Call Any Of Them, But The Code Stops Working!"