dholsinger
08-07-2003, 02:16 PM
I'm a novice javascripter with what seems like a simple problem that has totally got me stumped. I've got a simple pop-up window going with a session-long cookie which has worked well for the .htm pages I've used it on. Now I have to attach it to some .asp pages. If I hadn't tried this myself, I wouldn't believe it. So try this - save the code below (which contains no ASP) as popup.htm and again as popup.asp. When you call the .htm page (using IE 5+) the popup will function correctly. When you call the .asp page, nothing will happen.
code -----------------------------------
<html>
<head>
<script language="JavaScript">
function PopIt(){
popup = window.open("http://www.cnn.com?dn=1025","popDialog","top=1,left=1,height=320,width=260,scrollbars=no");
popup.window.focus();
}
function GetCookie (name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen) {
return 1;
break;
}
return null;
}
function SetCookie (name, value) {
document.cookie = name + "=" + escape (value);
}
function PopCode(){
var count = GetCookie('dnpopup')
if(count == null) {
SetCookie('dnpopup','1');
PopIt();
return 1;
}
}
</script>
</head>
<body onLoad="PopCode();">
Test
</body>
</html>
------------------------------------ code
If you view the source for both, they will be exactly the same. What causes the browser to treat the .asp page differently? Is it something in the header? How can I fix this?
Thanks!
:confused:
code -----------------------------------
<html>
<head>
<script language="JavaScript">
function PopIt(){
popup = window.open("http://www.cnn.com?dn=1025","popDialog","top=1,left=1,height=320,width=260,scrollbars=no");
popup.window.focus();
}
function GetCookie (name) {
var arg = name + "=";
var alen = arg.length;
var clen = document.cookie.length;
var i = 0;
while (i < clen) {
return 1;
break;
}
return null;
}
function SetCookie (name, value) {
document.cookie = name + "=" + escape (value);
}
function PopCode(){
var count = GetCookie('dnpopup')
if(count == null) {
SetCookie('dnpopup','1');
PopIt();
return 1;
}
}
</script>
</head>
<body onLoad="PopCode();">
Test
</body>
</html>
------------------------------------ code
If you view the source for both, they will be exactly the same. What causes the browser to treat the .asp page differently? Is it something in the header? How can I fix this?
Thanks!
:confused: