Dynamically Updating an IFrame Control via JavaScript

This is an advanced feature and requires an understanding of JavaScript and CallScripter fields.

 
 
The best way to update an IFrame Control's source currently is to use the below JavaScript in either a Calculate Field or JavaScript Button control.
The 2 lines of code above the "--------------------" are the ones that should be modified.
This is taken from the below example script with the named fields being:
  • News Section - is a List Control that  a text string is selected from. Ulmitaely as long as the JS variable "url" has the website url you wish to show the exact process you use to create this website url is irrelevent.
  • News IFrame - is the IFrame Control used to show the url to the agent
Every time this code is run the IFrame will reload (desired intention of setting the JS attribute "href" on the HTML IFrame element). 
 
//Make the new url string
var url = "http://www.bbc.co.uk/news/" + [News Section];

//Find the Control Number for the Control Name
var controlNumber = "getCSObject([News IFrame])".replace("F","");

//----------------------------------------------------------------------------

//Update the Iframe Control to show the new url
document.getElementById("csCon" + controlNumber).firstChild.contentWindow.location.href = url;
 
 
Note:
The double quotes around the getCSObject function are intentional in this case. As we want to get the resulting JS object as a text string name and not a true JS object.
In all normal uses of getCSObject this would not be the case.