I need to access a button inside an iframe through javascript. Below is the iframe code in the aspx file:
<iframe id="headerframe" runat="server" src="./DashHeader.html" marginheight="0" marginwidth="0" frameborder="0" style="width:inherit;height:inherit;overflow:hidden;">
</iframe>
There is a tab strip in the same file:
<telerik:RadTabStrip RenderMode="Lightweight" runat="server" ID="RadTabStrip1" Orientation="HorizontalTop" Width="100%" Height="32px" OnClientTabSelected="tabClicked" OnClientTabSelecting="savePreviousTab" SelectedIndex="0" >
</telerik:RadTabStrip>
When I try to access the control btnSearch(which belongs to the iframe) from the tabClick method of the tabstrip, I am able to find the button and perform the required action.
function tabClicked(sender, args) {
document.getElementById('headerframe').contentWindow.document.getElementById('btnSearch').style = "something";
}
But when I try to access the same control from a different custom javascript function, I am not able to access the required control.
function setSearchButtonVisibility()
{
document.getElementById('headerframe').contentWindow.document.getElementById('btnSearch').style = "something";
}
Please suggest what needs to be done in this case.