Open Window and show/hide Text

[Total: 0    Average: 0/5]

This example will open up a new window when the user clicks anywhere on the page that is not a link. It will also hide and show text string that is on the screen.

Head Code:

<script>
var isIE=document.all?true:false;
var isNS4=document.layers?true:false;
var isNS6=!isIE&&document.getElementById?true:false;
function openIt() {
  var _page = "http://www.js-examples.com/";
  var _name = "Messages";
  var _parms = "status=yes,top=100,left=200,width=250,height=1";
  window.open(_page,_name,_parms)
}
</script>

Body Code:

<div id="StartMenu">
This is the stuff inside the start-menu
</div>

<script name="startmenu"> 
onclick="openIt()"; // this statement should go inside the body tag to work best!
var h = "hidden"; 
var v = "visible"; 

function showMenu(_v)
{
  if(isIE)
    window.document.all.StartMenu.style.visibility = _v?v:h;
  if(isNS6)
    document.getElementById("StartMenu").style.visibility=_v?v:h;
  if(isNS4)
  {
    alert("This script will not run for NS4 because this DIV is positioned relatively and not absolutely!");
	/*
	 * This code would run if the DIV was positioned absolutely.
     * document.StartMenu.hidden=_v?"true":"false";
	 */
  }
}
</script> 
<a href="javascript:showMenu(true)">Show stuff</a><BR>
<a href="javascript:showMenu(false)">Hide stuff</a>

Times Viewed: 1

Leave a Reply

Your email address will not be published. Required fields are marked *