views:

67

answers:

0

I get different behaviour from my Javascript depending on if I write it or copy paste it myself from the already existing code or if I copy paste it from the Internet

This EXACT code gives different results depending on if the top two or bottom two are active:

var tt = 5;
alert(tt);
//CODE;
//CODE;
//var tt = 5;
//CODE;
//alert(tt);

This result in error 'tt is not defined'

//var tt = 5;
//alert(tt);
//CODE;
//CODE;
var tt = 5;
//CODE;
alert(tt);

This gives an alert box with a 5. I restarted the browser in between every time and I got the same result numerous times. I also tried to mix with having a space in between or not but somehow, it recognized which were written how.

Top one is written in Notepad++ by myself, bottom two copy pasted from a code snip on this site.

I use Notepad++ and browsers were IE6 and IE5.5.

Not very logical...


Ok, IE6 and IE5.5 seems to be VERY picky when it comes to exactly where the code is placed. Some places means the code is read and executed, others not and it's very systematic, once you see a pattern it's confirmed to you every time you try.

This for example:

//Från början är opacity'n 100 eftersom jag inte vet om Javascript är påsatt eller inte och därmed inte vet om PNG'arna kommer att
//bli genomskinliga eller ej. Är Javascript på så gör jag också bakgrunden genomskinlig så att PNG'arnas genomskinlighet inte blir i onödan
//If-satsen eftersom transparency ej existerar på första-sidan och därigenom ger fel där

if(document.getElementById('transparency') != null)document.getElementById('transparency').style.filter= "alpha(opacity=60)";

If the code is placed one line up, nothing happens (no error but nothing is carried out either), but placing it there and one row below always results in success whereas one row above ALWAYS results in the background not changing....