1

I've a js file located in my host http://mywebsite.com/data[0]/data[1]/test.js that has document.write() function in it.

( data[0] and data[1] are dynamic values that a php module handles them and js output would be different every time these values are chaneged)

when in a html file i use this :

<script src="http://mywebsite.com/data[0]/data[1]/test.js"></script>

it doesn't work but when i save an output of the js file (static values are set and no data[0] and data[1] are used ) in localhost and use this :

<script src="http://localhost/test.js"></script>

it works!

i think something in http request should be the problem but i don't know what !! : (

any help would be appreciated :(

revo
  • 47,783
  • 14
  • 74
  • 117
  • Does the resulting HTML contain `data[0]` or has it been replaceed by PHP? If it has been replaced, what is the resulting HTML? – pimvdb Nov 12 '11 at 11:16
  • @pimvdb, data[0] and data[1] are variables that module checks them and according to them js contents will differ. – revo Nov 12 '11 at 11:20
  • I'm not sure I understand your scenario. Is the file `data[0]/data[1]/test.js` literally requested? If not, what file is requested? – pimvdb Nov 12 '11 at 11:28
  • @pimvdb, please see my comment in George answer. – revo Nov 12 '11 at 11:39
  • `http://systemforoosh.com/ads/js/0/1` loads when navigating to it, but not as a ` – pimvdb Nov 12 '11 at 11:51

1 Answers1

0

Without seeing what data[0] or data[1] output I would guess it is these and you are incorrectly linking to the file.

If you are unable to post your website as an example I suggest you view the source (normally right click on the page and click view source) of your file and click the link (should be possible in most modern browsers) to your javascript file, if you don't see your javascript file you are linking to it incorrectly.

If you could link to the page I could help you further.

George Reith
  • 13,132
  • 18
  • 79
  • 148
  • when i click the link the contents are there but as clear as above that i said, it doesn't work in that condition. linking's correct. – revo Nov 12 '11 at 11:17
  • @Revo If linkage is correct then we would need to see the javascript code as it must be a js error. A link to your website would be good as I don't find your question clear. – George Reith Nov 12 '11 at 11:24
  • use this : use this : ` ` – revo Nov 12 '11 at 11:37
  • Your code makes no sense at `http://systemforoosh.com/ads/js/0/1` see: `var systemforoosh_rand = Math.floor(Math.random()*10000000); var systemforoosh_url = window.location.href.replace('http://','').replace('-','@#$@').replace(/\//g,'-'); var systemforoosh_src = 'http://systemforoosh.com/ads/show/0/1/'+systemforoosh_url+'/'+systemforoosh_rand; var new_script = ''; document.write(new_script);`you are adding a random number to the url between 1-999,999 so you are trying to load non existent js files. – George Reith Nov 12 '11 at 11:50
  • as also pimvdb said : http://systemforoosh.com/ads/js/0/1 loads when navigating to it, but not as a – revo Nov 12 '11 at 11:59
  • @Revo Try explicitly naming the file so instead of `http://systemforoosh.com/ads/js/0/1`search for `http://systemforoosh.com/ads/js/0/1.js` and putting that into the `` – George Reith Nov 12 '11 at 12:11