alex45 Posted October 28, 2006 Report Share Posted October 28, 2006 У меня есть код, но я не получается ввести глобальную переменную и из-за этого скрипт работает неправильно. Плиз помогите. СРОЧНО!!! Код: <html> <head> <script language="javascript"> var i = 0; function next(url,nomerimg,lastnomerimg) { i = nomerimg; if (i == lastnomerimg) { i = 0; } else { i = i++; } document["img"].src = url + i + ".jpg"; } function previous(url,nomerimg,lastnomerimg) { i = nomerimg; if (i == 0) { i = lastnomerimg; } else { i = i--; } document["img"].src = url + i + ".jpg"; } </script> <style type="text/css"> <!-- .style1 { font-family: "Courier New", Courier, monospace; font-size: 14px; text-decoration: none; } --> </style> </head> <body> <img src="a-0.jpg" name="img" width="95%" height="618"><br> <!-- linkbar --> <a href="#" class="style1" onClick="previous('a-',0,2)">previous</a> <a href="#" class="style1" onClick="next('a-',1,2)">next</a> </body> </html> Link to comment Share on other sites More sharing options...
Ф@РТОВЫЙ Posted October 29, 2006 Report Share Posted October 29, 2006 alex45: неправильная работа скрипта не из-за глобальной переменной! замени в двух местах: document["img"].src на: document.images["img"].src и этот тег: <img src="a-0.jpg" name="img" width="95%" height="618"> на этот: <img src="a-0.jpg" id="img" width="95%" height="618"> Link to comment Share on other sites More sharing options...
alex45 Posted October 30, 2006 Author Report Share Posted October 30, 2006 СПАСИБО Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now