[thelist] [fwd] Javascript and popups

Michele Foster michele at wordpro.on.ca
Tue Oct 16 23:46:17 CDT 2001


---------------------------
From: "Swanson, Gary" <gary.swanson at xwave.com>
Subject: Javascript and popups
Date: Tue, 16 Oct 2001 11:45:38 -0400

This is a forwarded message.  Please don't post multi-part or html messages
to
thelist.

Thanks!
------------------------------


Okay.

Here is my problem.  I am trying to create a popup that displays on a
submit.
---
<script LANGUAGE="javascript">

function db_update_popup(){
if (mywin) mywin.focus();
else
var mywin = window.open("/database_update.htm","popupwindow","top=0,
left=150,
toolbar=1,location=1,directories=0,status=1,menubar=0,resizable=1,scrollbars
=0,width=300,height=250");
}

</script>

 <input type="submit" src="/images/buttons/remove.gif" width="79"
height="18" border="0" name="DELETE" value="Remove"
onClick="db_update_popup()" onClick="return VerifyAction('You are about to
delete an announcemment!');" />

----
This brings the popup to front if the window is already open, or create a
popup if one isn't open.  This seems to work fine.
=============================

Then within the popup I am trying to set a cookie to determine if the user
no longer wants the popup to be displayed on every submit.

So I check for a cookie on focus or on load and then either pop the window
up on a delay or blur the window so that it stays in the background. If the
user selects the "don't show popups" button, I am trying to create a cookie
and blur the popup.  This unfortunately isn't working and  I am sure there
is a simpler way to do all of this.
---
<script language="javascript" type="text/javascript">
<!-- Hides code
  expireDate=new Date
  expireDate.setYear(expireDate.getDay()+1)

function createcookie () {
 if (document.cookie == "") {
  userName = "blank"
  document.cookie = "userName="+userName+";expires="+
expireDate.toGMTString()
  document.write("cookie created")
 }
}

function checkcookie () {
 if (document.cookie.split("=")[1] == "NoMorePopups") {
  document.write(document.cookie.split("=")[1])
  window.blur()
 }
else {
  setTimeout('self.focus()', 1000);
 }
}

function setCookie() {
 userName = document.myForm.nameField.value
 document.cookie = "userName="+userName+";expires="+
expireDate.toGMTString()
 window.blur()
}

// stop hiding-->
</script>
</head>
<body onfocus=checkcookie()>
<span onload=createcookie() />


<form name=myForm>
<input type="button" value="NoMorePopups" name="nameField"
onClick="setCookie()">
</form>
---

Any and all ideas / feedback would be greatly appreciated.

--Gary



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

This communication (including all attachments) is intended solely for the
use of the person or persons to whom it is addressed and should be treated
as a  confidential xwave communication.  If you are not the intended
recipient, any use, distribution, printing, or copying of this email is
strictly prohibited.  If you received this email in error, please
immediately delete it from your system and notify the originator.  Your
cooperation is appreciated.






More information about the thelist mailing list