1 2 3
document.write ('<noscript>\n'); document.write (imageClick); document.write ("</noscript>");
Refactorings
No refactoring yet !
Andre Steenveld
October 31, 2007, October 31, 2007 07:42, permalink
lol, how about not using document.write()? Since doing a write action on document is a javascript function by it self. Are you sure it wasn't a piece of serverside javascript though?
Robb
October 31, 2007, October 31, 2007 14:24, permalink
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173
//Globale Variable var Leerstring = " ist leer. Bitte geben Sie hier einen Wert ein." function ueberpruefeForm(form) { return (pruefeString(form.Vorname, "Vorname") && pruefeString(form.Name, "Name") && pruefeString(form.Strasse, "Strasse") && pruefeString(form.Hausnummer, "Hausnummer") && pruefeString(form.PLZ, "Postleitzahl") && pruefeString(form.Ort, "Ort") && pruefeEmail(form.Email, "E-Mail")) } function KontrolleNull(eingabe) { if ( eingabe.length == 0 ) { return false } else { return NurSpace(eingabe) } } function NurSpace(eingabe) { for ( var i=0; i<eingabe.length; i++ ) { if ( eingabe.charAt(i) != " " ) { return true } } return false } function zaehleZeichen(eingabe, anz) { if ( eingabe.length == anz ) { return true } else { return false } } function istZahl(eingabe) { for ( var i=0; i<eingabe.length; i++ ) { aktZeichen = eingabe.charAt(i) if ( aktZeichen < "0" || aktZeichen > "9" ) { return false } } return true } function ZahlinBereich(eingabe, unten, oben) { var zahl = parseInt(eingabe); return ((zahl >= unten) && (zahl <= oben)) } function pruefeString(eingabe, str) { if ( KontrolleNull(eingabe.value) && NurSpace(eingabe.value)) { return true } else { eingabe.focus() alert("Das Feld " + str + Leerstring) return false } } function pruefePLZ(eingabe) { if ( istZahl(eingabe.value) && zaehleZeichen(eingabe.value, 5) && ZahlinBereich(eingabe.value, 01000, 99999) ) { return true } else { eingabe.focus() alert("Ungültige PLZ - bitte überprüfen Sie Ihre Eingabe") return false } } function pruefeEmail(address) { email = address.value; format = /^(.+)@(.+)\.(.{2,3})/; format.exec(email); if (!(RegExp.$1 && RegExp.$2 && RegExp.$3)) { alert("Keine gültige E-Mail-Adresse!"); address.focus(); return false; }
Gary Haran
October 31, 2007, October 31, 2007 14:59, permalink
No sir. This was client side JS sent to us via an ad server. The entirity of their code is like that. They declare a variable and set a value to it and the next line they redeclare it with a different value. Everything about their ad server is random and it boggled my mind so much I thought I'd share.
I found this great piece of code from an ad server and thought to myself that I should learn to make my own JS legacy compliant. Can anyone please tell me if they know a better way to do this? Thanks in advance.