Uncaught SyntaxError: Unexpected identifier
Возникла проблема со скриптом вывода случайного фонового изображения в определенном айдишнике. Хром выдает ошибку Uncaught SyntaxError: Unexpected identifier и ссылается на строку document.getElementById:
Выглядит все примерно так: <body> <div id="fon"></div> <script type="text/javascript" language="Javascript"> var backgrounds=array(); backgrounds[0]="/img/back_web.png"; backgrounds[1]="/img/back_web2.png"; var rand=Math.Round(Math.Rand()*backgrounds.length); document.getElementById('fon').style.background='u rl('backgrounds[rand]') bottom no-repeat'; </script> </body> |
var backgrounds = new Array(); backgrounds[0] = '/img/back_web.png'; backgrounds[1] = '/img/back_web2.png'; var rand = Math.Round(Math.Rand()*backgrounds.length); document.getElementById('fon').style.background = 'url('+backgrounds[rand]+') bottom no-repeat'; |
Цитата:
<!DOCTYPE HTML> <html> <head> <title>Untitled</title> <style type="text/css"> div{ height: 30px; width: 30px; } </style> </head> <body> <div id="fon"></div> <script> var backgrounds = new Array(); backgrounds[0] = 'http://javascript.ru/forum/images/smilies/agree.gif'; backgrounds[1] = 'http://javascript.ru/forum/images/smilies/cray.gif'; var rand = Math.floor(Math.random()*backgrounds.length); document.getElementById('fon').style.background = 'url('+backgrounds[rand]+') bottom no-repeat'; </script> </body> </html> |
Ruslan_xDD,
рони, Спасибо огромное за помощь и извиняюсь за свое нубство. Тему можно закрывать. |
Часовой пояс GMT +3, время: 06:29. |