Pomoc - Szukaj - Użytkownicy - Kalendarz
Pełna wersja: [JavaScript]javascript nie działa na localhost a na zdalnym serwerze działa prawidłowo
Forum PHP.pl > Forum > Przedszkole
pafeu
javascript nie działa na localhost a na zdalnym serwerze działa prawidłowo
używam apache pod windows 7
w konsoli chrome dostaję komunikat:
Resource interpreted as Script but transferred with MIME type text/html: "http://localhost/OMMO/skrypty/translucentslideshow.js".
próbowałem już podpowiedzi, które wyczytałem w internecie ale nic nie pomaga
proszę o pomoc
sajegib
Kod
pafeu
Cytat(sajegib @ 28.01.2013, 20:26:28 ) *
Kod

  1. <script type="text/javascript" src="<?php echo DIR_SKRYPTY ?>translucentslideshow.js">
  2. /***********************************************
  3. * Translucent slideshow- (c) Dynamic Drive (www.dynamicdrive.com)
  4. * This notice MUST stay intact for legal use
  5. * Visit http://www.dynamicdrive.com/ for this script and 100s more.
  6. ***********************************************/
  7. </script>

  1. /* Translucent slideshow
  2. * Created: Jan 12th, 2011 by DynamicDrive.com. This notice must stay intact for usage
  3. * Author: Dynamic Drive at <a href="http://www.dynamicdrive.com/" target="_blank">http://www.dynamicdrive.com/</a>
  4. * Visit <a href="http://www.dynamicdrive.com/" target="_blank">http://www.dynamicdrive.com/</a> for full source code
  5. */
  6. jQuery.noConflict()
  7. function translideshow(options){
  8. var $=jQuery
  9. this.setting={displaymode:{type:'auto', pause:2000, cycles:0, pauseonmouseover:true}, orientation:'h', persist:true, slideduration:1000} //default settings
  10. jQuery.extend(this.setting, options) //merge default settings with options
  11. var curslide=(this.setting.persist)? translideshow.routines.getCookie("slider-"+this.setting.wrapperid) : 0
  12. this.curslide=(curslide==null || curslide>this.setting.imagearray.length-1)? 0 : parseInt(curslide) //make sure curslide index is within bounds
  13. this.curstep=0
  14. this.zIndex=1
  15. this.animation_isrunning=false //variable to indicate whether an image is currently being slided in
  16. this.posprop=(this.setting.orientation=="h")? "left" : "top"
  17. options=null
  18. var slideshow=this, setting=this.setting, preloadimages=[], slidesHTML=''
  19. for (var i=0; i<setting.imagearray.length; i++){ //preload images
  20. preloadimages[i]=new Image()
  21. preloadimages[i].src=setting.imagearray[i][0]
  22. slidesHTML+=translideshow.routines.getSlideHTML(setting.imagearray[i], setting.dimensions[0]+'px', setting.dimensions[1]+'px', this.posprop)+'\n'
  23. }
  24. jQuery(function($){ //on document.ready
  25. slideshow.init($, slidesHTML)
  26. })
  27. $(window).bind('unload', function(){ //on window onload
  28. if (slideshow.setting.persist) //remember last shown slide's index?
  29. translideshow.routines.setCookie("slider-"+setting.wrapperid, slideshow.curslide)
  30. })
  31. }
  32.  
  33. translideshow.prototype={
  34.  
  35. slide:function(nextslide, dir){ //possible values for dir: "left", "right", "top", or "down"
  36. if (this.curslide==nextslide)
  37. return
  38. var slider=this
  39. var nextslide_initialpos=this.setting.dimensions[(dir=="right"||dir=="left")? 0 : 1] * ((dir=="right"||dir=="down")? -1 : 1)//top-chowa slajd w dó3, down chowa slajd do góry
  40. var curslide_finalpos=-nextslide_initialpos
  41. var posprop=this.posprop
  42. if (this.animation_isrunning!=null)
  43. this.animation_isrunning=true //indicate animation is running
  44. //this.$imageslides.eq(dir=="left"||dir=="top"? nextslide : this.curslide).css("zIndex", ++this.zIndex) //increase zIndex of upcoming slide so it overlaps outgoing
  45. //this.$imageslides.eq(nextslide).css(translideshow.routines.createobj(['visibility', 'visible'], ['zIndex', ++this.zIndex], ['opacity', 0.3], [posprop, nextslide_initialpos])) //show upcoming slide - standardowo w31czone
  46. this.$imageslides.eq(nextslide).css(translideshow.routines.createobj(['visibility', 'visible'], ['zIndex', ++this.zIndex], ['opacity', 0.0], [posprop, nextslide_initialpos])) //show upcoming slide - zmieni3em sobie
  47. .animate(translideshow.routines.createobj([posprop, 0]), this.setting.slideduration, function(){
  48. jQuery(this).css('opacity', 1)
  49. slider.animation_isrunning=false
  50. })
  51. this.$imageslides.eq(this.curslide).animate(translideshow.routines.createobj([posprop, curslide_finalpos], ['opacity', 0]), this.setting.slideduration, function(){jQuery(this).css("visibility", "hidden")}) //hide outgoing slide - jak odkomentujemy t1 linijke to slajdy sie nak3adaj1 jeden na drugi - - doda3em opacity
  52. this.curslide=nextslide
  53. },
  54.  
  55. navigate:function(keyword){ //keyword: "back" or "forth", or "integer"
  56. clearTimeout(this.rotatetimer)
  57. var dir=(keyword=="back" || parseInt(keyword)<this.curslide)? (this.setting.orientation=="h"? "right" : "down") : (this.setting.orientation=="h"? "left" : "up")
  58. var targetslide=(keyword=="back")? this.curslide-1 : (keyword=="forth")? this.curslide+1 : parseInt(keyword)
  59. targetslide=(targetslide<0)? this.$imageslides.length-1 : (targetslide>this.$imageslides.length-1)? 0 : targetslide //wrap around
  60. if (this.animation_isrunning==false)
  61. this.slide(targetslide, dir)
  62. },
  63.  
  64. rotate:function(){
  65. var slideshow=this
  66. if (this.ismouseover){ //pause slideshow onmouseover
  67. this.rotatetimer=setTimeout(function(){slideshow.rotate()}, this.setting.displaymode.pause)
  68. return
  69. }
  70. var nextslide=(this.curslide<this.$imageslides.length-1)? this.curslide+1 : 0
  71. this.slide(nextslide, this.posprop) //go to next slide, either to the left or upwards depending on setting.orientation setting
  72. if (this.setting.displaymode.cycles==0 || this.curstep<this.maxsteps-1){
  73. this.rotatetimer=setTimeout(function(){slideshow.rotate()}, this.setting.displaymode.pause)
  74. this.curstep++
  75. }
  76. },
  77.  
  78. init:function($, slidesHTML){
  79. var slideshow=this, setting=this.setting
  80. this.$wrapperdiv=$('#'+setting.wrapperid).css({position:'relative', visibility:'visible', overflow:'hidden', width:setting.dimensions[0], height:setting.dimensions[1]}) //main DIV
  81. if (this.$wrapperdiv.length==0){ //if no wrapper DIV found
  82. alert("Error: DIV with ID \""+setting.wrapperid+"\" not found on page.")
  83. return
  84. }
  85. this.$wrapperdiv.html(slidesHTML)
  86. this.$imageslides=this.$wrapperdiv.find('div.slide')
  87. this.$imageslides.eq(this.curslide).css(translideshow.routines.createobj([this.posprop, 0])) //set current slide's CSS position (either "left" or "top") to 0
  88. if (this.setting.displaymode.type=="auto"){ //auto slide mode?
  89. this.setting.displaymode.pause+=this.setting.slideduration
  90. this.maxsteps=this.setting.displaymode.cycles * this.$imageslides.length
  91. if (this.setting.displaymode.pauseonmouseover){
  92. this.$wrapperdiv.mouseenter(function(){slideshow.ismouseover=true})
  93. this.$wrapperdiv.mouseleave(function(){slideshow.ismouseover=false})
  94. }
  95. this.rotatetimer=setTimeout(function(){slideshow.rotate()}, this.setting.displaymode.pause)
  96. }
  97. }
  98.  
  99. }
  100.  
  101. translideshow.routines={
  102.  
  103. getSlideHTML:function(imgref, w, h, posprop){
  104. var posstr=posprop+":"+((posprop=="left")? w : h)
  105. var layerHTML=(imgref[1])? '<a href="'+imgref[1]+'" target="'+imgref[2]+'">' : '' //hyperlink slide?
  106. layerHTML+='<img src="'+imgref[0]+'" style="border-width:0;" />'// <<<<<<<<<<<<<<<<<<<<<<<<<<<----------------------tutaj można dodać width aby dopasować baner <<<<<<<<<<<<<<<<<---------------------------------------------------------------------
  107. layerHTML+=(imgref[1])? '</a>' : ''
  108. return '<div class="slide" style="position:absolute;'+posstr+';width:'+w+';height:'+h+';text-align:center;">'
  109. +'<div style="width:'+w+';height:'+h+';display:table-cell;vertical-align:middle;">'
  110. +layerHTML
  111. +'</div></div>' //return HTML for this layer
  112. },
  113.  
  114.  
  115. getCookie:function(Name){
  116. var re=new RegExp(Name+"=[^;]+", "i"); //construct RE to search for target name/value pair
  117. if (document.cookie.match(re)) //if cookie found
  118. return document.cookie.match(re)[0].split("=")[1] //return its value
  119. return null
  120. },
  121.  
  122. setCookie:function(name, value){
  123. document.cookie = name+"=" + value + ";path=/"
  124. },
  125.  
  126. createobj:function(){
  127. var obj={}
  128. for (var i=0; i<arguments.length; i++){
  129. obj[arguments[i][0]]=arguments[i][1]
  130. }
  131. return obj
  132. }
  133. }
Michasko
Więc skoro szukałeś, to może powiedz nam czego już próbowałeś, żebyśmy się nie powtarzali wink.gif
Problem nie tkwi w kodzie, a konfiguracji serwera/systemu bądź pliku .htaccess.
pafeu
Cytat(Michasko @ 28.01.2013, 21:07:16 ) *
Więc skoro szukałeś, to może powiedz nam czego już próbowałeś, żebyśmy się nie powtarzali wink.gif
Problem nie tkwi w kodzie, a konfiguracji serwera/systemu bądź pliku .htaccess.

np: zmieniałem mime plików .js w regedit, w apache dodałem AddType text/javascript .js
.htaccess też odpada bo sprawdziłem
dodam, że jakiś czas temu, chyba w poprzedniej wersji php plik .js działał bezproblemowo na localhost
po aktualizacji do nowej wersji przestał działać
Michasko
A czy korzystasz normalnie z innych funkcjonalności pliku .htaccess?
Czy ustawienia serwera pozwalają na nadpisywanie reguł "globalnych" za pomocą plików .htaccess umiejscowionych w konkretnych katalogach?
pafeu
używam .htaccess i wszystko normalnie działa
To jest wersja lo-fi głównej zawartości. Aby zobaczyć pełną wersję z większą zawartością, obrazkami i formatowaniem proszę kliknij tutaj.
Invision Power Board © 2001-2025 Invision Power Services, Inc.