Forum Moderators: open

Message Too Old, No Replies

Make DIV/Layer visible in another frame?

         

fille

12:30 pm on Mar 28, 2002 (gmt 0)



Please, anyone!

The command comes from frame nr 4, and I want to write every code in frame nr 4 and only have the layer/div visible in frame nr 6

If I reference to an object in frame 6 there won't be any object there. Is there another way?

All this in the same document.
--------------beginning nav.doc--------
...
layerRef="parent.frames[6].document.all"
//layerRef="document.all";
//window.top.rightframe.showlayer(true)//ns
styleSwitch=".style";
visibleVar="visible";
}
}
function showHideLayerSwitch(layerName)
{
if (eval (layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility == visibleVar'))
hideLayer(layerName);
else
showLayer(layerName);
}
function showLayer(layerName)
{
eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="visible"');
}
....
document.writeln(" <div id="+i2+" ><ahref=\"javascript:showHideLayerSwitch('"+i2+y+"');\" style=\"…..position: absolute; z-index: "+not_hidden_z+"; left: "+not_hidden_left+"px; top: "+not_hidden_top+"px; \"> ¦ " + nav[i2]+ "</a>");
….
document.writeln("<style type=text/css>");
document.writeln("#"+(i2-1)+y+" {position: absolute; z-index: "+hidden_z+"; visibility: hidden; left: "+hidden_left+"px; top: "+hidden_top+"px;}");
document.writeln("</style>");
document.writeln("<div id="+(i2-1)+y+">");
.....
---------end nav.doc-----------------

([1]edited by: tedster at 4:25 pm (utc) on Mar. 28, 2002)

tedster

4:51 pm on Mar 28, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I can't see why the object wouldn't be there. Can you clarify?

fille

1:04 am on Mar 29, 2002 (gmt 0)



OK,
If I have two frames (nr 0 and nr 1)
Then I have to place some code in the document in frame 1 like this
______ n_top.asp ___________
<%@ Language="JavaScript" %>
<html><head>
<title></title>
<script language=javascript>
<!--
//global variables
var visibleVar="null";
var layerRef="null",styleSwitch="null",visibleVar="null";
function init()
{
if (navigator.appName == "Netscape")
{
layerRef="document.layers";
styleSwitch="";
visibleVar="show";
}
else
{
layerRef="parent.frames[1].document.all"
//layerRef="document.all";
styleSwitch=".style";
visibleVar="visible";
}
}
function showHideLayerSwitch(layerName)
{
if (eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility == visibleVar'))
hideLayer(layerName);
else
showLayer(layerName);
}

function showLayer(layerName)
{
eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="visible"');
}
function hideLayer(layerName)
{
eval(layerRef+'["'+layerName+'"]'+styleSwitch+'.visibility="hidden"');
}
//-->
</script>

</head>
<body bgcolor="#bbffgg" onload="init(); " bgproperties="fixed">
<div id=aa ><a href="javascript:showHideLayerSwitch('ab');" style="font-family:verdana; font-weight:bold ; color:black; text-decoration:none; position: absolute; z-index:100; left:30px; top:20px; ">första menyn</a>
</body>
</html>
----- End file n_top.asp ----

The following file need some code too, but I don’t want this code in the file because this frame is the target of the sub in the DIV.

----- File content.asp ------
<html>
<head>
</head>
<body>
<style type="text/css"> #ab {position: absolute; z-index: 70; visibility: hidden; left: 33px; top: 36px;}</style>

<div id=ab>
<a href=#>ab sub 1</a><br>
<a href=#>ab sub 2</a><br>
<a href=#>ab sub 3</a><br>
</div>
</body>
</html>

tedster

3:46 am on Mar 29, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



In the second frame, the <style></style> declaration should be in the HEAD, not in the BODY.

That's why the visibility of the object/layer ab isn't available from the first frame - it never gets defined in the first place.

fille

9:51 am on Mar 29, 2002 (gmt 0)



I see what you mean but is it possible to declare everything in the first frame instead?
I want too keep all my code in the first frame.
Otherwise the declaration is reloaded every time I press a sub link.
And even better would bee if I could open the layer over two frames!
I guess now it’s impossible?

tedster

12:52 pm on Mar 29, 2002 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Right - each frame is like its own window, and a layer is inside a window.

So if you want to give a particular div a style of any kind, the css must be in the window where that div "lives".