View Full Version : <input...OnClick won't work with Mac's??
CitznFish
11-21-2002, 11:24 PM
OK, I am having a huge problem when developing a survey in a pop-up window. I can get it to work exactly as planned on a PC, but on a Mac it doesn't. this is one of those 'Am i too dumb to figure this out?' situations.
My problem is as follows:
I have a pop-up window that appears on my homepage. This pop-up contains a 6 question multiple choice survey. I have this working correctly, but I do not want guests to see the results until they are published at a later date. I have it set to close the pop-up window once they submit their results. So what I did was add an onClick to the <input...> tag. Here is the last line of my survey code:
<input type="submit" value="Submit" onClick="javascript:window.close()" width="40" height="20"></div>
</form>
Now this works perectly in Netscape and IE on a PC, but on a Mac it processes the quiz and shows the results page. Am i missing something here? I have been searchign through JS books and the web all day looking for an answer to this problem. Please help before my head explodes! :) Thank you all so much!
P.S., I have tried many many variations of onClick in the <input..> tag, nothing seems to work for the Mac..
This is IE 5 and NS 4.72 for the Macintosh
I currently have this live if you want to see it as-is...
http://familyfun.go.com
requestcode
11-21-2002, 11:59 PM
Have you tried using the onSubmit event in the Form tag? You could use it to perform a script that would close the window.
CitznFish
11-22-2002, 12:25 AM
Originally posted by requestcode
Have you tried using the onSubmit event in the Form tag? You could use it to perform a script that would close the window.
Thank you for the quick response. I have tried the onSubmit but had the same problems. It just doesn't seem to want to work in a Mac.
here is my code for the OnSubmit..I think it's correct as far as I can tell. It does work on the PC..
<head>
<script language="javascript">
function closeWin() {
window.close()
}</script>
</head>
<form action="http://***.***.***.com/cgi-bin/quiz/quiz.cgi" method="post" onSubmit="closeWin()" >
chrismiceli
11-22-2002, 12:55 AM
i think it is javascript: not java script and if it isn't why not do onSubmit="closeWin()" ??
glenngv
11-22-2002, 12:59 AM
remove the window.close() method in the quiz page.
Instead, the quiz.cgi should output html like this:
<html>
<head>
<script>
window.close();//close at once
</script>
</head>
<body>
<!--Provide some message in case javascript is disabled-->
The quiz has been checked and the results will be published later.<br>
Please standby...
<p><form><input type="button" value="Close" onclick="window.close()"></form>
</body>
</html>
I'd recommend that you should not close the window at once without any displaying any message to the user. I suggest that you remove the window.close() at the head and just provide a message and a close button.
CitznFish
11-22-2002, 01:03 AM
Originally posted by chrismiceli
i think it is javascript: not java script and if it isn't why not do onSubmit="closeWin()" ??
Yeah, that was a typo when I made the post..sorry.
Also I have tried onSubmit="window.close", onSubmit="closeWin()", and every other variation you can think of. IE on the Mac just seems to want to ignore this.....
CitznFish
11-22-2002, 01:34 AM
Originally posted by glenngv
remove the window.close() method in the quiz page.
Instead, the quiz.cgi should output html like this:
<html>
<head>
<script>
window.close();//close at once
</script>
</head>
<body>
<!--Provide some message in case javascript is disabled-->
The quiz has been checked and the results will be published later.<br>
Please standby...
<p><form><input type="button" value="Close" onclick="window.close()"></form>
</body>
</html>
I'd recommend that you should not close the window at once without any displaying any message to the user. I suggest that you remove the window.close() at the head and just provide a message and a close button.
I wish I could do this, but I developed the quiz so that our Editors could review the results by submitting a blank form. Also the quiz works in such a way so that when you Submit your choices you are taken to the results page. Since this quiz.cgi is used by multiple websites i cannot edit the output (They won't let me, and if they did we are talking about weeks of time spent bickering about costs). The definition file I use for the Quiz.cgi has to have a results page, i just need to hide it from guests visiting the site. (meaning it has to be seamless to the guest. They submit the results andthe window disappears) :)
CitznFish
11-22-2002, 02:00 AM
Any Mac experts out there?? :) I am begining to think it's just not going to work. On a mac it seems to want to process the entire CGI script for the quiz and NOT perform any onClick or onSubmit events....
even onUnload didn't work...
Again, you can try it if you have a Mac at this URL:
http://familyfun.go.com (uses a session cookie to stop multiple quizes coming up during a session)
craigh@mac.com
11-22-2002, 02:18 AM
have you tried <BUTTON></BUTTON> instead of <INPUT>?
I'm using OSX Mac IE 5.2 and took your poll. The window stayed open as you describe.
CitznFish
11-22-2002, 02:41 AM
Originally posted by craigh@mac.com
have you tried <BUTTON></BUTTON> instead of <INPUT>?
I'm using OSX Mac IE 5.2 and took your poll. The window stayed open as you describe.
Craig,
Thank you for the help. I didn't even think of <button> because I am unfamiliar with how it works. I went ahead and tried it and it closes the window. However, it also stops the survey data from posting. I looked at W3C's Button documentation (http://www.w3.org/TR/REC-html40/interact/forms.html#edef-BUTTON) but it wasn't helpful to me (the 'Value' key is confusing me)
Here is how I set it up:
<BUTTON NAME="submit" VALUE="modify" onClick="window.close()">Submit</BUTTON>
It doesn't post the survey data when used on a PC either... I am probably doing something wrong with <Button>, but what?? :confused:
craigh@mac.com
11-22-2002, 03:02 AM
add: type="submit"
CitznFish
11-22-2002, 05:55 PM
Originally posted by craigh@mac.com
add: type="submit"
I had tried that last night and of course it then counted the survey results correctly AND took the guest to the results page. It just doesn't work on the Mac. I think my next step is to just detect OS's and not allow Mac users to take the survey.. I really don't know what else to do.
THANK YOU all for your suggestions and ideas.
Poor Mac users no longer get to take the quiz. If ANYBODY can figure out how to fix this bug I have been dealing with I'll forever be grateful. Until then this is what I am using...
<script language="JavaScript">
var PLATFORM = "WIN";
if ((navigator.userAgent.indexOf("Mac") > -1)){
PLATFORM = "MAC";
} else {
PLATFORM = "WIN";
}
if (!GetCookie("fam21surveycookie") && PLATFORM=="WIN") {
SetCookieEZ("fam21surveycookie",1,"/");
popupWindow = window.open("/Resources/global/survey/index.html","survey","width=357,height=400,scrollbars=yes");
}
function GetCookie (name) {
var result = null;
var myCookie = " " + document.cookie + ";";
var searchName = " " + name + "=";
var startOfCookie = myCookie.indexOf(searchName);
var endOfCookie;
if (startOfCookie != -1) {
startOfCookie += searchName.length; // skip past cookie name
endOfCookie = myCookie.indexOf(";", startOfCookie);
result = unescape(myCookie.substring(startOfCookie, endOfCookie));
}
// alert(result);
return result;
}
function SetCookieEZ (name, value, path) {
document.cookie = name + "=" + escape(value) + ((path) ? "; path=" + path : "");
}
//-->
</script>
Well, I'm not sure if the form is getting submitted or not, but with your code I tried:
<form name="f1" method="post" action="your action here ">
...form code
<input type="button" name="submit" id="submitButton" value="Submit" onclick="document.f1.submit(); window.close();" />
</form>
It closes the window, but I don't know if the form is being submitted. A good solution might just be to have a "thank you for participating" page, which the user will see upon submitting the form. Then, you could just have a button or link on that page to close the window... or have it close automatically after a certain amount of time.
hope this helps. I'm on a Mac running OS 9.2, IE 5.1.6 btw...
CitznFish
11-22-2002, 07:37 PM
Originally posted by bk1
Well, I'm not sure if the form is getting submitted or not, but with your code I tried:
<form name="f1" method="post" action="your action here ">
...form code
<input type="button" name="submit" id="submitButton" value="Submit" onclick="document.f1.submit(); window.close();" />
</form>
It closes the window, but I don't know if the form is being submitted. A good solution might just be to have a "thank you for participating" page, which the user will see upon submitting the form. Then, you could just have a button or link on that page to close the window... or have it close automatically after a certain amount of time.
hope this helps. I'm on a Mac running OS 9.2, IE 5.1.6 btw...
Thaks for the advice. :) Unfortunately this didn't post the survey data.... What are the odds that this is some undocumented compatibility bug? :confused:
This Forum is great! i am very happy I discovered it!
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.