jquery iframe src

前端 未结 2 1358
猫巷女王i
猫巷女王i 2021-01-25 22:12

I have an HTML page containing an iframe and I am trying to write functions on links in the iframe. The functions will make changes in the HTML page...

The following scr

2条回答
  •  说谎
    说谎 (楼主)
    2021-01-25 22:21

    try to use the .live() method, it binds an event to the existing elements and future elements. When you change the src, you need to bind again the click event to the new links.

    I don't know if the .live() method works on a iframe but you can try this:

      $("iframe").contents().find("a").live('click',function() {
        alert('Load was performed.');
      });
    

    Sorry for my broken english!.

    i don't know if it will works (sorry I don't have where to test things now), but what happens if you try to bind an function on the onLoad event of your iframe, (even if W3C says that iframe has no events, it appears to be supported by all browsers):

        
        ...
       
    

提交回复
热议问题