www.webdeveloper.com
Results 1 to 2 of 2

Thread: hopefully simple question about javascript and frames

  1. #1
    Join Date
    Aug 2010
    Posts
    10

    hopefully simple question about javascript and frames

    I'm building a webpage using javascript and iframes. Basically I have an iframe in the middle of the index.html page that links to another html page (let's call it iframe.html). My question is, is it possible to call a javascript function from iframe.html to control an object on index.html? If so, how do I do this? I'd like to be able to assign an image in iframe.html with the hyperlink of href="javascript:function()", where the function effects the CSS of a div on index.html.

    Thanks

  2. #2
    Join Date
    Apr 2003
    Location
    Netherlands
    Posts
    21,654
    Adds a handler to the first image in index.html
    Code:
    parent.document.getElementsByTagName('img')[0].onclick=function(){parent.foo();};
    The pseudo-protocol javascript: is unnecessary in 99% of cases; no need to use it.
    Add function calls to a handler, onclick, onmouseover etc., not to the anchor event.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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



Recent Articles