Javascript undefined variable Firefox

Soldato
Joined
6 Aug 2007
Posts
2,516
Hi,

I'm working with SharePoint.

I have some Javascript that i am using to show or hide fields depending on what tab the user is viewing.

As of now the code works fine in IE7 / 8. But does not work in Firefox / Opera.

The error i am recieving is: "TypeError: control is undefined".

http://pastebin.com/FDLEbygD

Anyone have any ideas?
 
Bit of a long shot as I can't remember off the top of my head, but is there a difference between the way the browsers treat case-sensitiveness in JavaScript? 'findacontrol' seems strangely named, should really be findAControl.

It shouldn't make a difference as "findacontrol" is a function, as long as all the callings match it should be working as intended.

I can't help with your specific problem, but my advice would be to throw that away and write it from scratch. The code is appalling - so much needless repetition.

Also, how come jQuery is being included but you're using native javascript? jQuery would make that whole script about 10 lines long. It would also deal with the issue of having to use different methods to get access to the DOM in different browsers - which is seemingly the cause of your problem.

You are right, it is appalling, but as far as i know this is the best way to approach this when using SharePoint. We are very restricted in how we can hide the fields.

jQuery is included by accident, I didn't remove it after finding out that SharePoint + jQuery don't get on well at all.

Thanks.
 
Last edited:
After a bit of experimenting it's due to your ! tags.

IE 7 and 8 recognise them but IE 9 and firefox don't.

http://pastebin.com/p9tbXX2W

Lob that in a file and test it out.

That does indeed seem to be the case.

I've tried alternatives such as "*" and even blank. None work the same, does anyone know an alternative to getElementsByTagName("!") that will simply grab all the tags, whilst still being compatable across multiple Browsers?

Thanks.
 
Hey guys,

Just a quick update.. i scrapped the Javascript and managed to get jQuery working.

The only problem is when I'm using jQuery IE is extremely slow when clicking tabs.. Firefox, Safari, Opera, Chrome all load them instantly.

This is a problem as most of the users will be using IE.

Anyone have any ideas on how to speed this up a little?

http://pastebin.com/E1u16Y4D

Thanks in advance.
 
Back
Top Bottom