Necesito acceder a un botón dentro de un iframe a través de javascript. A continuación se muestra el código iframe en el archivo aspx:
<iframe id="headerframe" runat="server" src="./DashHeader.html" marginheight="0" marginwidth="0" frameborder="0" style="width:inherit;height:inherit;overflow:hidden;"> </iframe>Hay una tira de pestañas en el mismo archivo:
<telerik:RadTabStrip RenderMode="Lightweight" runat="server" ID="RadTabStrip1" Orientation="HorizontalTop" Width="100%" Height="32px" OnClientTabSelected="tabClicked" OnClientTabSelecting="savePreviousTab" SelectedIndex="0" > </telerik:RadTabStrip>Cuando trato de acceder al control btnSearch (que pertenece al iframe) desde el método tabClick de la barra de pestañas, puedo encontrar el botón y realizar la acción requerida.
function tabClicked(sender, args) { document.getElementById('headerframe').contentWindow.document.getElementById('btnSearch').style = "something"; }Pero cuando trato de acceder al mismo control desde una función javascript personalizada diferente, no puedo acceder al control requerido.
function setSearchButtonVisibility() { document.getElementById('headerframe').contentWindow.document.getElementById('btnSearch').style = "something"; }Por favor, sugiera lo que se debe hacer en este caso.