I have a function that loads an html file into an iframe
in my code I have an areaCode:function LoadIFrame(file) { ContentWindow.innerHTML = "<iframe width=455 height=446 src='" + file + ".htm' frameborder='0'></iframe>"; }
And when someone clicks on a image linkCode:<div id="ContentWindow"></div>
Code:<a href="#"><img src="images/News.jpg" id="News" onClick="LoadIFrame('News');window.focus();"></a>
Now all this works just as I expect. But what I want to is to have more than one IFrame that can be loaded so I want to be able to pass in which area the iframe should be loaded
Code:function LoadIFrame(file,frame) { frame.innerHTML = "<iframe width=455 height=446 src='" + file + ".htm' frameborder='0'></iframe>"; }However when I try this it no longer works. I'm fairly new to Javascript, so is there some I can do so I can pass in the ID to make this possible or would I have to make some sort of if else statement (although that would be undesirable since I would like to make this as flexible as possible and work with any site I'm working on)Code:<a href="#"><img src="images/News.jpg" id="News" onClick="LoadIFrame('News','ContentWindow');window.focus();"></a>




Reply With Quote