Change the src of iFrame and submit
Many web applications use iFrames for getting around the Javascript issues. The use of iFrame helps in replacinga placeholder for reloading the contents and avoiding the reload of other components on the web page.
This iFrame tutorial discusses how to set or change the source location of an iFrame and also submit it to the server so that the contents of iFrame get updated based on the URL to which it is now pointing.
This example should come handy in situation where you want to create an iFrame with blank src attribute and then change the src attribute by using javascript.
The following code shows how to perform this step:
myFrm = document.getElementById('myFrm');
var frameDoc;
if (downloadFrm.contentDocument)
frameDoc = downloadFrm.contentDocument;
else // bad Internet Explorer ![]()
frameDoc = downloadFrm.document;
frameDoc.location.href = "http://myurl.com";
In the above code, we are getting the iFrame document object and then changing the href attribute of this iFrame by making it point to the appropriate URL.
You may find other source which make use of the src attribute and try to change it by using javascript. I had also used the src attribute of iFrame and tested on various browsers before having a cross browser way of reloading an iFrame.
If you have used the above javascript iFrame reload snippet, then do leave a comment.
