Weird error -- getting only in Chrome

error:

[INDENT]Uncaught TypeError: Cannot call method ‘indexOf’ of null (repeated 3 times)
[/INDENT]

I’m getting this error only in Chrome, not even Safari… (and not FF… don’t know about IE, can’t test on IE now…)

what is this… I have never seen this before… (this error has to do with method indexOf(), but my use of it here is very conventional… for example…

if (loc.indexOf('localhost') != -1) {
   .......
}

so what is this error…

thank you…

Hi there,

Can you post a link to a page where I can see this error?

now it’s doing something different…

now when I press “submit” on the form the window is dimmed and it says “paused in debugger”… this only occurs in Chrome…

I’m not sure I can post a url…

why does Chrome do this… (also Chrome has a hard time refreshing updated .js files… I once heard Chrome compiles javascript files… I don’t know what the purpose of this is, but it’s not a very good idea if it doesn’t always update the src code and recompiles it every time it changes…:wink:

ok, that was a setting in Chrome Dev tools (“mouse” was turned on under “breaking points” don’t know when that changed…)

it’s back to same error I was having before… I can’t post a url, but here’s a screenshot, I hope it helps to see the problem…

the email gets sent, but b/c of error in “success” function the “thank you” part doesn’t print…

this line

[FONT=Courier New]if (loc.indexOf('resume') != -1) {[/FONT]

var ‘loc’ is null ONLY IN CHROME… how can this be? in FF it’s fine…

[FONT=Courier New]function Success() {

	console.log('loc success -- ' + loc);
	........
}[/FONT]

prints fine in FF, it prints current url, in Chrome it prints ‘null’…

???

thank you…

PS: Chrome has a real problem updating JS files too… this is a huge pain… yes we can do ctrl-F5… but… are we supposed to put a note on pages for users that if you’re in Chrome that’s how you have to reload the page if it’s not working??? :wink: I don’t get why Chrome does this…

Hi there,

It’s really hard to say without seeing the page.
I can’t really deduce anything from the screen shot.
Sorry.

One way around this is to add a ?<version> to the script src link:

<script type="text/javascript" src="myfile.js?123"></script>

See here for other suggestions: http://stackoverflow.com/questions/8392441/stop-chrome-caching-my-js-files

thank you… I fixed it but the prob was really weird… (and the fix is weird too…)

this is what my prob was…
http://stackoverflow.com/questions/7039995/global-js-variables-not-available-to-functions-defined-in-included-js-files

i.e., in Chrome only, a global variable was not available inside a function, so I had to decl it again inside the fn… very very weird…

thank you…

how does this force it to update the js code? (and, in Chrome’s case, compile again from newly-updated js code?)

thank you…

Hi there,

That is weird, I’ve not heard of that before.
For example the following will work as expected in Chrome (where message is a global variable):

var message = "Hello!";
function sayHello(){
  alert(message);
}
sayHello();

I’m guessing you had quite a bit more going on on your page.
At least you got it sorted now :slight_smile:

You increment the version number and Chrome will recognize it as a new file and re-load it from the server.

E.g. You have this:

<script type="text/javascript" src="myfile.js?123"></script>

and you update myfile.js.
For whatever reason Chrome decides that it can use its cached version of myfile.js, so doesn’t load the new version of the file.
But if you change the query string, e.g.

<script type="text/javascript" src="myfile.js?124"></script>

then Chrome will reload the file without any further prompting.

Hope that helps.