how to set masterpage dom element in contentpage with javascript
a div in asp.net masterpage,i want hide it in one of its content page ,so I add this js at the end of content page
if (document.getElementById('sitemap'))
189 document.getElementById('sitemap').display = "none";
div sitemap in materpage, when i debug this js,document.getElementById('sitemap') run ok,but it can't be hiden .why? if I want set materpage's dom element style in content page,how to 开发者_Python百科do this? thanks.
you're missing the style-member:
document.getElementById('sitemap').style.display = "none";
If it's a .Net control(ASP:Panel), leave a hook in your Masterpage to access it, otherwise Dr.Molle's answer is what you need:
Masterpage:
function HideSiteMap()
{
document.getElementById('" + sitemap.ClientID + "').style.display = "none";
}
Contentpage:
Call the function.
精彩评论