• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

SOLUTION! function that works in script tag but not in js file

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I am having bizarre (to me) problems with js files and IE. Basically I have a webpage which loads a js file that has a bunch of utility-type functions that I've written. IE balks at one particular function within that file (Mozilla doesn't have any problem with it). When I move the function out of the js file and into the html file, IE then has no problem. If I move it back again, IE gives me an error.

Here is the function:



IE gets as far as the alert "id was string", then stops with the error.

Any ideas?

Thank you!! Karen.
[ February 04, 2007: Message edited by: Karen Nelson ]
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

then stops with the error.



What error? Granted, IE error messages border on the criminally unhelpful, but let us know what the error message is in any case.
 
author
Posts: 15385
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is your code getting called before the elements are on the page (calling before onload?

Eric
 
Karen Nelson
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The error message was the standard "object expected", followed by "identifier expected". The line numbers in the error message don't even correspond to lines that contain code in my files.

I call the function from window.onload, standard stuff.

It works perfectly in Mozilla. It also works perfectly as long as I define the function directly in the html file in a script tag, OR (I have since found out) if I make a new js file called util-DOM-2 and stick it in there. But of course I have already used the original util-DOM.js on a few hundred webpages. Is it possible for IE to think that the js file is somehow corrupted? Other functions in this file still work fine in IE.
 
Karen Nelson
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey, I figured it out (only took about 5 hours)...

I usually use "//-----" as a header for a block of functions that belong together. One time I messed up and wrote "//******", which should be OK but IE interpreted as beginning a comment. So nothing after that statement worked, and even stuff before it seemed unreliable at best.

I'm trying to decide if debugging with IE is more or less useful than a Ouija board.

-Karen.
 
Bear Bibeault
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You'll have better luck with the Ouija board.
 
reply
    Bookmark Topic Watch Topic
  • New Topic