(X)HTML, JavaScript, DHTML, XML, CSS Client scripting tehnologije, Dynamic HTML, Cascading Stylesheets, XML i standardi |
|
Alati teme | Način prikaza |
28. 02. 2013. | #1 |
član
Certified
Datum učlanjenja: 06.09.2012
Poruke: 64
Hvala: 0
342 "Hvala" u 10 poruka
|
Javascript cookies
Imam jedan problem sa cookie-em, kod radi Internet Exploreru, Mozili, Operi, al ne radi Google Chrom-u, napravio sam da se reklama svaki put promeni kad se refresuje stranica, jel ima neko neko resenje kod je sledeci:
<!DOCTYPE HTML> <html> <head> <meta charset="utf-8"> <title>Untitled Document</title> <script language="javascript" type="text/ecmascript"> function getCookieValue(cookieName) { var cookieValue = document.cookie; var cookieStartsAt = cookieValue.indexOf(" " + cookieName + "="); if (cookieStartsAt == -1) { cookieStartsAt = cookieValue.indexOf(cookieName + "="); } if (cookieStartsAt == -1) { cookieValue = null; } else { cookieStartsAt = cookieValue.indexOf("=", cookieStartsAt) + 1; var cookieEndsAt = cookieValue.indexOf(";", cookieStartsAt); if (cookieEndsAt == -1) { cookieEndsAt = cookieValue.length; } cookieValue = unescape(cookieValue.substring(cookieStartsAt, cookieEndsAt)); } return cookieValue; } function setCookie(cookieName,cookieValue, cookiePath, cookieExpires) { cookieValue = escape(cookieValue); if (cookieExpires == "") { var nowDate = new Date(); nowDate.setMonth(nowDate.getMonth() + 6); cookieExpires = nowDate.toGMTString(); } if (cookiePath != "") { cookiePath = ";Path=" + cookiePath; } document.cookie = cookieName + "=" + cookieValue + ";Expires=" + cookieExpires + cookiePath; } </script> </head> <body> <img src="sl/AdvertImage1.jpg" name="imgAdvert"> <script> var imageNumber = getCookieValue("displayedImages"); var totalImages = 3; if (imageNumber == null) { imageNumber = "1"; } else { imageNumber = Math.floor(imageNumber) + 1; } if (totalImages == imageNumber) { setCookie("displayedImages","","","Mon, 1 Jan 1970 00:00:00"); } else { setCookie("displayedImages",imageNumber,"",""); } document.imgAdvert.src = "sl/AdvertImage" + imageNumber + ".jpg"; </script> </body> </html> |
28. 02. 2013. | #2 |
Душан Бошкић
Qualified
|
Chrome ignoriše cookies sa/iz lokalnih stranica. Postavi na lokalni (a da nije localhost, 127.0.0.1)/live server.
__________________
In brightest day, in blackest night ... Poslednja izmena od 35-68 : 28. 02. 2013. u 19:21. Razlog: localhost |
28. 02. 2013. | #3 |
član
Certified
Datum učlanjenja: 06.09.2012
Poruke: 64
Hvala: 0
342 "Hvala" u 10 poruka
|
Nije, ja direktno u browser-u pokrecem, nisam instalirao nijedan xampp ili wamp server, jel ovo su primeri iz knjige ucim javascript. Znaci ako se sajt upload-uje na serveru onda ce normalno cookie da radi u google chromu?.
|
28. 02. 2013. | #4 | |
Душан Бошкић
Qualified
|
Citat:
Srećno sa učenjem.
__________________
In brightest day, in blackest night ... |
|
02. 03. 2013. | #5 |
član
Certified
Datum učlanjenja: 06.09.2012
Poruke: 64
Hvala: 0
342 "Hvala" u 10 poruka
|
Hvala
|
02. 03. 2013. | #7 |
Душан Бошкић
Qualified
|
https://www.google.rs/search?q=chrom...alhost+domains
Tako je bar bilo pre par godina, hvala na kratkom obajšnjenju/podesećanju http i file protokola A, da bi zbunili stanketa još više moje localhost okruženje je http://*.35.68
__________________
In brightest day, in blackest night ... |
|
|