Wikipedia:Reference desk/Archives/Computing/2015 December 13
Computing desk | ||
---|---|---|
< December 12 | << Nov | December | Jan >> | December 14 > |
Welcome to the Wikipedia Computing Reference Desk Archives |
---|
The page you are currently viewing is an archive page. While you can leave answers for any questions shown below, please ask new questions on one of the current reference desk pages. |
December 13
[edit]How to close current page in HTML/Javascript (on all platforms) ?
[edit]Note that the current page is not one that I opened with Javascript (let's say the user clicked on a link after a Google search to get here). I tried:
window.close();
This only seems to work on some platforms. I found many suggestions online, but none that work on all platforms I tested (Chrome, Firefox, Opera, and IE). Any ideas ?
Thanks, StuRat (talk) 02:54, 13 December 2015 (UTC)
- MDN says you're only allowed to call window.close() on a window that was opened with window.open(). So you can't close arbitrary windows with JavaScript. (Thankfully. I don't want scripts closing my windows whenever they feel like it.) --71.119.131.184 (talk) 22:33, 13 December 2015 (UTC)
Javascript clue?
[edit]I have a quiz with 10 questions (each question should bring 10 points if answered correctly). Each question is a yes or no question. Whenever a user clicks on the right answer a string "Y" (Y) appears, and when ever it clicks on the wrong answer an "X" (X) appears.
My question is, if I want that every Y to bring +10 points, and every X to bring -10 points to the total possible sum of 100 hundred points, what is the right way to do that? How could I use each printed Y\X to add or subtract 10 points?
Thanks, Ben-Yeudith (talk) 16:22, 13 December 2015 (UTC)
- You could concatenate them all into a 10 character string, then loop through the string, and examine each character, and add or subtract the points for each. However, it would seem to me that you already have an if-then statement for each Q that decides whether it was answered correctly or not, so you might as well just adjust the total inside that if-then, rather than do it later (initialize the total to 0 at the start of the quiz). Also note that the -10 for a wrong answer is typically done to dissuade quiz-takers from just guessing, and this implies that skipping a Q they don't know how to answer should also be an option. StuRat (talk) 22:11, 13 December 2015 (UTC)
- I just slapped this together a couple weeks ago to help my class study for a final. View the source code to see if it helps. [1] 209.149.113.52 (talk) 14:37, 14 December 2015 (UTC)