How to make the iframe's to call my function remotely?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Revathi Balakrishnan
    New Member
    • Jun 2008
    • 40

    How to make the iframe's to call my function remotely?

    i am trying to disable some of the anchor tags which are linked with particular onmouseover and onmouseout events.i have written a javascript function.when i called this function on load of the document body, it is able to disable the tags.But when the body of the page has iframes, this script is unable to disable the tags with in the iframes. since "document.getel emetbytags" is not returning the anchor tags with in the iframe.so i need to put this script in the iframe source file and i need to call this function on load of the body of the iframe. since my site has so many iframes i would need to repeat this task so many times.

    Without even including the script in the iframe source file, and the below code on all the iframe tags,

    onload=javascri pt:linkdisablin g function();

    is there any way to make the iframes to call and access this function onload ?

    please notify me if my question is unclear .
  • gits
    Recognized Expert Moderator Expert
    • May 2007
    • 5390

    #2
    in your iframe's onload just call something like that:

    [CODE=javascript]
    parent.disable_ my_nodes(docume nt);
    [/CODE]
    so just pass the document to the function and note that the shown example works when the iframe is a direct child of your document ... otherwise you may use top or parent.parent for example.

    kind regards

    Comment

    • Revathi Balakrishnan
      New Member
      • Jun 2008
      • 40

      #3
      how to make my iframe to call my script

      This code works very well, Thanks alot for the reply.

      but i still have a probelm in implementing this.
      My Web site has large number of iframes, and the content of the iframe starts in one file and ends in another file,so inserting a body tag and an onload method in the body tag becomes a bit difficult. hence i thought of inserting the below javascript to all my iframes , but it does not work.
      Code:
        <script type="text/javascript">
                   document.body.onLoad = link disabling_function (document) {
                      function body
                  }
              </script>
      help me to spot the problem in this script.
      Is there any other way to make this function to be called onload of the iframe content.

      Comment

      • gits
        Recognized Expert Moderator Expert
        • May 2007
        • 5390

        #4
        i don't get it ... could you give a simplified example for the structure you are using? one page, one iframe with it's example content, and how yuo use the javascript code in it? this should make it clear where the problem would be.

        kind regards

        Comment

        • Revathi Balakrishnan
          New Member
          • Jun 2008
          • 40

          #5
          To make my iframe to access my javascript function i thought of inserting the below tag in my iframes.
          <body onload="link disabling_funct ion (document) ;">
          </body>
          but most of my iframe's content starts in one file and ends in another file,
          hence to insert a body tag for an iframe i require to change two files for an iframe.
          Hence without doing this if i thought of including the below script in all iframe's content.
          <script type="text/javascript">
          document.body.o nLoad = link disabling_funct ion (document)();
          </script>

          But the script does not work.

          Please help me to make the script work, or suggest me a method , to call this function [link disabling_funct ion]onLoad of the iframe.

          Comment

          • Revathi Balakrishnan
            New Member
            • Jun 2008
            • 40

            #6
            i would like to know, if there is any other method ,which would make my iframes to call my function onLoad, with out even inserting anycode in the iframe content.

            Comment

            • gits
              Recognized Expert Moderator Expert
              • May 2007
              • 5390

              #7
              are all iframes-contents from your domain and does they not! have an onload already?

              Comment

              Working...