SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Guru
    Join Date
    Nov 2005
    Location
    Midwest
    Posts
    777
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problems calling JavaScript function from <object>

    Hello

    I am having difficulty calling a JavaScript function when the user clicks on a Flash movie.

    Here is basically what I have.

    Code:
    <a href="javascript:SomeJavaScriptFunction();">
       <object>
          <param name="movie" value="movie.swf">
       </object>
    </a>
    When I click on the Flash Movie, it does not call the JavaScript function. If I put text after the <a href tag, the JavaScript function works so I know it has something to do with the object. Is there a way I can make the <object> call a JavaScript function without changing the Flash?

    Any help would be appreciated.

    Thanks

  2. #2
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    <object> tags are supposed to have onclick event handlers, but I couldn't get one to work in IE6 or FF.

  3. #3
    SitePoint Wizard
    Join Date
    Mar 2001
    Posts
    3,537
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Actually, this works in FF:

    <embed onclick="alert('hello')>
    </embed>

  4. #4
    SitePoint Zealot
    Join Date
    Dec 2006
    Posts
    182
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Since you're using Flash, why not call the function when someone clicks on a button inside the flash object?

  5. #5
    SitePoint Guru
    Join Date
    Nov 2005
    Location
    Midwest
    Posts
    777
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thank you for the responses. We did end up changing the Flash but I still think there has to be a way to accomplish this. For example, there are a lot of site out there that have Flash advertisements. I just assumed they used code to redirect users to the correct spot in there site instead of having the Flash changed for every site the code runs on.

    As for the <embed onclick> code, I was not able to get that to work.

    Thanks again for the responses.


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
  •