watagal Posted May 5, 2006 Share Posted May 5, 2006 GreetingsI'm playing around with <div> tag and can toggle their display on/off using (in same frame) this java script: function togDiv(sDivID) { var oDiv = document.getElementById(sDivID); oDiv.style.display = (oDiv.style.display == "none") ? "block" : "none";} Now I want to toggle the <div> in another frame, how can I rewrite this js to access a <div> element in another frame?Thanks, Link to comment Share on other sites More sharing options...
Little Goat Posted May 5, 2006 Share Posted May 5, 2006 top.frames[0].getElementById(sdivid)change the zero to access diferent frames: 0=first 1=second...LG Link to comment Share on other sites More sharing options...
watagal Posted May 5, 2006 Author Share Posted May 5, 2006 top.frames[0].getElementById(sdivid)change the zero to access diferent frames: 0=first 1=second...LG<{POST_SNAPBACK}> Thanks, is there a way to refer to the frame by ID name (ie "frmMain")?Thanks again, Link to comment Share on other sites More sharing options...
Nakor Posted May 5, 2006 Share Posted May 5, 2006 Just put the name of the frame. top.Framename.getElementById(sdivid) Link to comment Share on other sites More sharing options...
watagal Posted May 5, 2006 Author Share Posted May 5, 2006 Just put the name of the frame. top.Framename.getElementById(sdivid) <{POST_SNAPBACK}> Thanks, I tried it both ways and I get no action:/*function togPanel(iFrame,sDivID) { if (iFrame != -1) var oDiv = top.frames[iFrame].getElementById(sDivID) else var oDiv = document.getElementById(sDivID); oDiv.style.display = (oDiv.style.display == "none") ? "block" : "none";}*/function togPanel(sFrame,sDivID) { if (sFrame != "") var oDiv = top.+sFrame+.getElementById(sDivID) else var oDiv = document.getElementById(sDivID); oDiv.style.display = (oDiv.style.display == "none") ? "block" : "none";}In the first function (commented out now) - I get "Object dosesn't support method". And in the 2nd function, I get "Object Expected" error.A little bit more help please.Thanks, Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now