Created
January 19, 2017 22:40
-
-
Save mvcaaa/b27d0d7e213e94ddd84a19142ff0bd6e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!-- | |
| /** | |
| * Created by Astashov Andrey <[email protected]> | |
| * Date: 20.01.2017 / 01:00 | |
| */ | |
| --> | |
| <script> | |
| var objs = { | |
| "1":{ | |
| "count":10, | |
| "price":200 | |
| }, | |
| "2":{ | |
| "count":1, | |
| "price":500 | |
| }, | |
| "16":{ | |
| "count":1, | |
| "price":500 | |
| }, | |
| }; | |
| function summarize(objs) { | |
| var sum = 0; | |
| for (var i in objs) { | |
| sum += objs[i].price * objs[i].count | |
| } | |
| return sum; | |
| } | |
| /** | |
| * Этот код перестал работать в браузере chrome с 2016-06-02 | |
| * см. https://www.chromestatus.com/feature/5349061406228480 | |
| * Тестировать в EDGE/IE | |
| * Переписать - гуглить спецификацию и как оно реализовывается. | |
| */ | |
| window.onbeforeunload = function () { | |
| return "Summ is: "+ summarize(objs) + ". Continue ?"; | |
| } | |
| </script> | |
| <a href="#2">Link</a> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment