Click to See Complete Forum and Search --> : collapsing function not working in Netscape.


isubeatle
07-19-2004, 11:53 AM
i have 3 frames and i'm using javascript to "hide" the top frame when a link is clicked on in the middle frame.

so here's what i have in my frameset



<script type="text/javascript">

var columntype=""
var defaultsetting=""

function getCurrentSetting(){
if (document.body)
return (document.body.cols)? document.body.cols : document.body.rows
}

function setframevalue(coltype, settingvalue){
if (coltype=="rows")
document.body.rows=settingvalue
else if (coltype=="cols")
document.body.cols=settingvalue
}

function resizeFrame(contractsetting){
if (getCurrentSetting()!=defaultsetting)
setframevalue(columntype, defaultsetting)
else
setframevalue(columntype, contractsetting)
}

function init(){
if (!document.all && !document.getElementById) return
if (document.body!=null){
columntype=(document.body.cols)? "cols" : "rows"
defaultsetting=(document.body.cols)? document.body.cols : document.body.rows
}
else
setTimeout("init()",100)
}

setTimeout("init()",100)

</script>


here is the link that i'm using in the middle frame

<a href="javascript: parent.resizeFrame('0,20,*')">link</a>


it's works in IE of course but won't work in Netscape, even Netscape 7.0. For some reason it refreshes the page instead of just adjusting the frames. can anyone help me?

thanks

gil davis
07-19-2004, 07:01 PM
Netscape does not access frame things like cols and rows through the document.body object, because they are really windows. Since there are no such objects in the DOM for NS, you have script errors that you could see by accessing Tools|Web Development|Javascript Console in NS 7. The errors would leave the browser with no options when you click the link except to refresh.

BTW, it is not advisable to use the "javascript:" URL for such actions. Instead, use the onclick.
<a href="#" onclick="resizeFrame('0,20,*');return false">