Jump to content

Accessing <div> in another frame


watagal
 Share

Recommended Posts

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

Just put the name of the frame.
top.Framename.getElementById(sdivid)

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...