Picker in Popup

[Total: 0    Average: 0/5]

This file will allow the user to click an HREF link to open up a new window.

Body Code:

<script>
var myWin=null;
var _code="";
function start()
{
  var _popupURL="popup_sel_and_rewrites_ii.html"; /* set if you want to define the code in another window */
      _popupURL=""; /* use all code on this page */
  var _winDefs=""; /* set if you want to have the window properties defined */
  /* this _code definition is the code for the popup (if popupurl is not defined */
      _code ="<html>";
      _code+="<head>";
      _code+="<title>Picker</title>";
      _code+="</head>";
      _code+="<body onunload='opener.document.myWin=null;'>";
      /* this next method (#1) will ship the selection into the opener document hidden form */
	  _code+="<"+"script>function choice(_v,_tf){alert(_v);if(!_tf)opener.document.hf.hv.value=_v;else opener.processChange(_v);window.close();}<"+"/script>";
	  _code+="<a href='javascript:choice(1,false)'>Choice 1</a>";
	  _code+="<a href='javascript:choice(2,false)'>Choice 2</a>";
	  _code+="<a href='javascript:choice(3,false)'>Choice 3</a>";
	  _code+="<HR>";
	  /* this next method (#2) will directly call the change routine */
	  _code+="<a href='javascript:choice(4,true)'>Choice 4</a>";
	  _code+="<a href='javascript:choice(5,true)'>Choice 5</a>";
      _code+="</body>";
      _code+="</html>";
  myWin=window.open(_popupURL,"w1",_winDefs);
  /* this next if block will write to popup code if the url is not specified */
  if(!_popupURL)
  {
    /* this timer is necessary when the popup takes a while to open - may been to increase time from 1000 milliseconds (1 second) */
    setTimeout("    myWin.document.open(); myWin.document.write(_code);	myWin.document.close();	",1000); /* wait 1 second */
  }
  myWin.focus();
}
</script>
<script>
var ELEMENT_TO_CHANGE="elm";
function processChange(_v)
{
  if(document.getElementByID)
  {
    /* if is IE6 or NS6 */
    document.getElmentByID(ELEMENT_TO_CHANGE).innerHTML=_v;
  }
  else if(document.all)
  {
    /* if is IE4, IE5 */
    eval("document.all."+ELEMENT_TO_CHANGE+".innerHTML='"+_v+"'");
  }
  else
  {
    /* if NS4 (any other browser) */
    document.location=document.location.toString().split("?")[0]+"?"+_v;
  }
}
</script>
<a href="javascript:start()">Click here to open window and make choices</a>
<HR>
<!--
  -- This hidden form is used for method #1
  -->
<form name=hf>
<input type=hidden name=hv value="">
</form>
<script>
var LAG_HV=document.hf.hv.value;
function detectChange()
{
  var currentHV=document.hf.hv.value;
  if(currentHV!=LAG_HV)
  {
    LAG_HV=currentHV;
    processChange(currentHV);
  }
}
setInterval("detectChange()",500); /* start the detection effort */
</script>
<table border=1><tr><td>
<div id=elm><script>
var _def="default";
if(document.location.search.indexOf("?")!=-1)
{
  _def=document.location.search.split("?")[1];
}
document.write(_def);
</script></div>
</td></tr></table>

Times Viewed: 2

Leave a Reply

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