why doesnt ONCLICK work from some machines?

Discussion in 'Javascript' started by Andrew, Jul 27, 2004.

  1. Andrew

    Andrew Guest

    Hi all

    Are there any compatibilty issues associated with teh following command?

    <div onclick="open('http://www.mysite.com.htm','','')">Main page </div

    It worked on a PC butnot on a MAC (bith with IE).

    Thanks

    atskud
     
    Andrew, Jul 27, 2004
    #1
    1. Advertising

  2. Andrew wrote:
    > Hi all
    >
    > Are there any compatibilty issues associated with
    > teh following command?
    >
    > <div onclick="open('http://www.mysite.com.htm','','')">Main page </div


    Yes.

    > It worked on a PC butnot on a MAC (bith with IE).


    The unqualified identifier - open -, executed form on event handler,
    will be resolved against the scope chin of the event handler function.
    Browsers construct different custom scope chains for the event handling
    functions that they construct (from attribute strings), and those scope
    chains may or may not include the - document - object, which has an -
    open - method of its own. If Mac IE places the - document - on the DIVs
    onclick handler's scope chain then the method called will be -
    document.open - instead of - window.open -. Not relying on identifier
    resolution against the scope chain when placing code in HTML event
    handling attribute strings avoids the problem (i.e. use - window.open -
    in this case).

    All calls to - window.open - may be subject to pop-up blocking
    mechanisms of various sorts, and thus may not work on all
    machines/configurations even with the same browser.

    Very old browsers (e.g. Netscape <= 4) may not implement onclick
    handlers on normal DIV elements.

    Richard.
     
    Richard Cornford, Jul 27, 2004
    #2
    1. Advertising

  3. Andrew

    kaeli Guest

    In article <>,
    enlightened us with...
    > Hi all
    >
    > Are there any compatibilty issues associated with teh following command?
    >
    > <div onclick="open('http://www.mysite.com.htm','','')">Main page </div
    >
    > It worked on a PC butnot on a MAC (bith with IE).
    >


    Try
    <div onClick="window.open('http://www.mysite.com/page.htm','','');">Main
    </div>

    Mac IE may not support just using open without window in front.
    Just a guess. I don't have a Mac to test it on.

    --
    --
    ~kaeli~
    If that phone was up your a$$, maybe you could drive a
    little better!
    http://www.ipwebdesign.net/wildAtHeart
    http://www.ipwebdesign.net/kaelisSpace
     
    kaeli, Jul 27, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Showjumper
    Replies:
    5
    Views:
    457
    Showjumper
    Jul 17, 2003
  2. Replies:
    3
    Views:
    382
    Matt Parker
    Feb 28, 2004
  3. Mr. SweatyFinger
    Replies:
    2
    Views:
    2,216
    Smokey Grindel
    Dec 2, 2006
  4. Janaka Perera
    Replies:
    0
    Views:
    1,189
    Janaka Perera
    Oct 29, 2007
  5. Replies:
    3
    Views:
    461
    alex23
    May 27, 2008
Loading...

Share This Page