Results 1 to 4 of 4

Thread: image link - using both onClick & onDblClick

  1. #1
    Join Date
    May 2006
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default image link - using both onClick & onDblClick

    Hi there,

    I'm trying to get one image to serve as two links, depending on the type of event handler that's used. If a user clicks once with their mouse, webpage1 should load in an iframe called EC Content. (EC = event calendar). Likewise, if a user double clicks, webpage2 should load into EC Content.

    The result of my simple efforts is that href is processed wonderfully by IE, NS, and Mozilla Firefox, but onDblClick won't work in any of the three browers.

    I used this approach:
    <a href="next_meeting.htm" target="EC Content" onDblClick="parent.frames['EC Content'].location='bottom.htm';"><img src="calendar_mainpage.jpg"></a>

    I suspect the problem is linked to the hierarchy of event handlers, which has href/onClick evaluated before onDblClick, and of course, the fact that onDblClick calls onClick into action, making things worse.

    I found javascript code that separates the two actions (with a delaying technique), but I'm failing to correctly replace the alert function with code that will have webpage1 and webpage2 load into the correct iframe (EC Content).

    Here's a link to the javascript code: http://www.webxpertz.net/forums/show...?threadid=2188

    *look towards the bottom and you'll see it.

    I've tried: self.document.location.href="webpage2.htm"; which works, but since it doesn't encompass the name of the iframe I want to target, webpage2.htm does not load into the right iframe. The word "self" is messing things up.

    I'm not experienced at writing Javascript, although I've looked at a lot of it. lol. Does anyone have a suggestion?

  2. #2
    Join Date
    May 2006
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default I got it

    I figured it out. I'm so silly sometimes.

    This is the code I eventually came to:
    frames['EC Content'].document.location.href="webpage2.htm";

    When you replace the alert function with it, the javascript works like a charm.

  3. #3
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    If you add return false to it, like:
    onDblClick="function(); return false;"

    the link won't load.... as it is now, you're likely loading the href, then the dblclick link. So... it works, but you wouldn't really want to load the href first.
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  4. #4
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    I'd suggest:
    Code:
    <a href="next_meeting.htm" target="EC Content" onclick="return false;" ondblclick="parent.frames['EC Content'].location='bottom.htm';return false;"><img src="calendar_mainpage.jpg"></a>
    That should cause the least confusion.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends franšais | entiendo espa˝ol | t˘i Ýt hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •