• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

JS Function not getting invoked from inside the iframe

 
Ranch Hand
Posts: 80
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello,

I have a folder which contains html and js file. The js file is included in the html via path reference.
html file is having 5 icons which when clicked invoked functions defined in js file.
So far all working fine.

Next in the same folder, I created one more html2 and called it inside html ( main) via iframe.
In html2 i moved 3 out of 5 clickable icons. So main html is having 2 icons and a iframe which shows html2 ( with three icons)

The 2 icons in main html is still working fine when invoked but the 3 icons in html2 is not working.
Any clue what needs to be done here to make it work.

Regards,
Faraz
 
author & internet detective
Posts: 41860
908
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
To restate, you have three files: 2 HTML and on JavaScript. The original HTML can access the JavaScript file, but the new one can't. Do they both reference the external file using the exact same line of code?
 
whippersnapper
Posts: 1843
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How are you selecting the icons in the iframe to attach the click handlers? In jQuery, for example, to select your image (by id) on the main html you could do something like this:

$('#icon1');

But if that image is now inside an iframe, your selector needs to reach inside the iframe like this:

$('#iframe1').contents().find('#icon1');

(Sorry, I don't know the plain JavaScript for that.)
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic