• 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

Popup dialog at mouse position... works in IE, not Firefox

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is a basic script that should pop up once the object is clicked... It works in IE, but not Firefox. Any thoughts?

 
Sheriff
Posts: 67748
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
Please take the time to choose the correct forum for your posts. This forum is for questions on beginning Java.

For more information, please read this.

This post has been moved to a more appropriate forum.

 
Bear Bibeault
Sheriff
Posts: 67748
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
Please read this. Telling us "it doesn't work" does nothing to help us help you.

What does happen? What errors are shown? Is there anything in the FireBug console? Have you examined the contents of variables along the way to determine where the error occurs?

Show some effort.
 
Chris Huber
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
*Note - made minor edit to code

I get 'event is not defined' in Firefox at the line:

if (!event) {

I've see then if(!event){...} code used often for non-IE work arounds, so I'm not sure that is what I am doing wrong.
 
Bear Bibeault
Sheriff
Posts: 67748
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

Chris Huber wrote: so I'm not sure that is what I am doing wrong.


Well, look at your function. Where is event defined? Of course you are going to get an 'undefined error' on any variable, including the event instance, that is not defined.

IE, which still does not follow the standard event model (don't get me started), plops the instance on the window, which is why your code is working for IE. But for the real browsers that follow the standards, you can't just expect the event instance to fall from heaven. Rather, it is passed to the event handler as its first parameter.

As you are using the onclick attribute to define your handler (not the best of practices), the handler function is implicit and so is the event parameter. Therefore the event parameter is available in the implicit handler and you can pass it to your function.

So your new onclick declaration should be:


I'll leave it to you to redefine your function accordingly.
 
Chris Huber
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok, thanks for the help. It works now.
 
Bear Bibeault
Sheriff
Posts: 67748
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
Make sure that you understand why!


 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic