Click to See Complete Forum and Search --> : OnClick and Layers


StaticEdge
01-27-2005, 08:40 PM
Hey guys, two questions:
1) Is there a way to setup a link so that when someone clicks it, the link makes a layer visible? Or something along those lines?

2) When you set up a link to pop-up a window how do you set the size of that window?

Thank you!
-StaticEdge
www.phasenine.net

Green-Beast
01-28-2005, 08:33 AM
You can call an array using JavaScript:

Apply script type here if put in document head (or it can be linked):
<!--
var ie4 = (document.all) ? true : false;
var ns4 = (document.layers) ? true : false;
var ns6 = (document.getElementById && !document.all) ? true : false;
function hidelayer(lay) {
if (ie4) {document.all[lay].style.visibility = "hidden";}
if (ns4) {document.layers[lay].visibility = "hide";}
if (ns6) {document.getElementById([lay]).style.display = "none";}
}
function showlayer(lay) {
if (ie4) {document.all[lay].style.visibility = "visible";}
if (ns4) {document.layers[lay].visibility = "show";}
if (ns6) {document.getElementById([lay]).style.display = "block";}
}
function writetolayer(lay,txt) {
if (ie4) {
document.all[lay].innerHTML = txt;
}
if (ns4) {
document[lay].document.write(txt);
document[lay].document.close();
}
if (ns6) {
over = document.getElementById([lay]);
range = document.createRange();
range.setStartBefore(over);
domfrag = range.createContextualFragment(txt);
while (over.hasChildNodes()) {
over.removeChild(over.lastChild);
}
over.appendChild(domfrag);
}
}

var txtArray = new Array();
txtArray[0] = "Text, links and-or images for array zero";
txtArray[1] = "Text, links and-or images for array one";
txtArray[2] = "Text, links and-or images for array two";
txtArray[3] = "Text, links and-or images for array three";
//-->
...and so on

And in the document call them as so:

<a class="" href="javascript:writetolayer('newlayer',txtArray[0]);" title= "Tool Tip">Link Text or image</a>
<a class="" href="javascript:writetolayer('newlayer',txtArray[1]);" title= "Tool Tip">Link Text or image</a>
<a class="" href="javascript:writetolayer('newlayer',txtArray[2]);" title= "Tool Tip">Link Text or image</a>
<a class="" href="javascript:writetolayer('newlayer',txtArray[3]);" title= "Tool Tip">Link Text or image</a>

To show the content here in this Div:
<div id="newlayer" class="newlayer">
Arrays show here
</div>

This script seems to work on everything. If you use it please credit http://gbhxonline.com in your document.

-------------------------------

Regarding a popup, I am assuming you have what you need to make it work, so all you need is a to size it. Do it like so:
<!--
function PopupName() { window.open('PopupName.html',
'POPUP NAME','width=400,height=400,resizable=no,scrollbars=yes'); }
//-->
Other attributes such as the status bar may also be turned on or off. Do provide window controls (i.e. Close Popup) and make them on-call, not automatic.