Hi, I have Javascript code that behaves as it is supposed to in Firefox, Chrome and Opera. But in IE9, it does not behave correctly. When I change the Document Mode from "Quirks" to "IE9 standards" manually, it works very well. I need some code that will do this automatically when the page loads. I tried <!DOCTYPE html> before <html> tag, but I was successless. The page should work good in IE9, Firefox, Chrome and Opera. I will appreciate your help. The code is below:
Code:<?php // Check if session is not registered , redirect back to main page. // Put this code in first line of web page. // Kullanıcı giriş yapmadan direkt bu web sayfasının adresini yazarsa, bu web sayfası açılmaz giriş sayfasına yönlendirilir. session_start(); if(!session_is_registered(myusername)){ header("location:main_login.php"); } ?> <html> <link href="tez_ana.css" rel="stylesheet" type="text/css"> <!-- <table width="768" border="0"> <tr> <td> --> <title> Akış Kontrol Deyimleri </title> <body> <SCRIPT LANGUAGE="JavaScript"> function msjYazdir(gelen_deger) { if ( gelen_deger == 'if (60 < $not) {' ) { document.kosul.mesaj_kutusu.value = "Yanlış cevabı seçtiniz. Karşılaştırma operatörü seçimini hatalı yaptınız."; // aşağıdaki 3 satır, 3. satıra seçilen şıktaki ifadeyi atar ve tüm kodu tekrar textArea'ya yazdırır. var satirlar = document.kosul.kod_yazim_alani.value.split("\n"); satirlar [2] = " if (60 < $not) {"; document.kosul.kod_yazim_alani.value = satirlar.join("\n"); // "\n" karakterini birleştirme karakteri olarak kullanarak array'i string'e atar. document.kosul.yanlis_secim_sayisi.value = document.kosul.yanlis_secim_sayisi.value + 1; // yanlis_secim_sayisi gizli textbox'unun value'sına her yanlış seçiminde string olarak 1 karakteri ekleniyor. En sonunda doğruyu seçtiğinde .length fonksiyonu ile kaç tane 1 karakteri var bu sayılıyor ve böylece doğruyu seçmeden önce kaç kere yanlış seçim yaptığı saptanıyor. Bu sayıya da 1 sayısı eklendiğinde kaçıncıda doğru şıkkı bildiği ortaya çıkıyor. } else if ( gelen_deger == 'if ($not < 60) {' ) { document.kosul.mesaj_kutusu.value = "Doğru cevabı seçtiniz.\n\"Tüm Kodu Dene\" düğmesine tıklayarak sonucu görebilirsiniz."; var satirlar = document.kosul.kod_yazim_alani.value.split("\n"); satirlar [2] = " if ($not < 60) {"; document.kosul.kod_yazim_alani.value = satirlar.join("\n"); // "\n" karakterini birleştirme karakteri olarak kullanarak array'i string'e atar. document.kosul.mesaj_kutusu.style.backgroundColor = "#F66"; setTimeout ("bir_sure_kirmizi_yap()", 1000); if (document.kosul.bir_defa_dogru_cavabi_buldu.value == "") { var yapilan_ornek = "if deyimi örnek 3"; var kacincida_dogru_cevabi_buldu = document.kosul.yanlis_secim_sayisi.value.length + 1; var xmlhttp; if (window.XMLHttpRequest) { xmlhttp = new XMLHttpRequest; } else { xmlhttp = new ActiveXObject ("Microsoft.XMLHTTP"); } var url = "http://localhost/tez/ornek_tamamlama_bilgisini_vt_gonder.php?hangi_ornek=" + yapilan_ornek +"&kacinci_secimde_dogru_cevabi_buldu="+kacincida_dogru_cevabi_buldu; xmlhttp.open("GET", url, false); xmlhttp.send(null); } document.kosul.bir_defa_dogru_cavabi_buldu.value = 1; } else if ( gelen_deger == 'if {$not < 60} {' ) { document.kosul.mesaj_kutusu.value = "Yanlış cevabı seçtiniz. Koşul kısmında parantez yerine küme parantezi kullandınız."; // aşağıdaki 3 satır, 3. satıra seçilen şıktaki ifadeyi atar ve tüm kodu tekrar textArea'ya yazdırır. var satirlar = document.kosul.kod_yazim_alani.value.split("\n"); satirlar [2] = " if {$not < 60} {"; document.kosul.kod_yazim_alani.value = satirlar.join("\n"); document.kosul.yanlis_secim_sayisi.value = document.kosul.yanlis_secim_sayisi.value + 1; } else if (gelen_deger == 'if {$not =< 60} {') { document.kosul.mesaj_kutusu.value = "Yanlış cevabı seçtiniz. Koşul kısmında parantez yerine küme parantezi kullandınız ve karşılaştırma operatörü seçimini hatalı yaptınız."; var satirlar = document.kosul.kod_yazim_alani.value.split("\n"); satirlar [2] = " if {$not =< 60} {"; document.kosul.kod_yazim_alani.value = satirlar.join("\n"); document.kosul.yanlis_secim_sayisi.value = document.kosul.yanlis_secim_sayisi.value + 1; } } function bir_sure_kirmizi_yap () { document.kosul.mesaj_kutusu.style.backgroundColor = "#FFC"; } String.prototype.trim = function() { return this.replace(/^\s+|\s+$/g,""); } // örnekte kullanılan ifadenin yapısını içeren bir yardım function ipucu_goster () { document.kosul.mesaj_kutusu.value = "KOMUT YAPISI\n-------------\n if (koşul) {\n komut;\n }"; } </SCRIPT> <form name = "kosul" action = "" method ="POST"> <input type="hidden" name="yanlis_secim_sayisi" id="yanlis_secim_sayisi" value="<?php echo $_POST['yanlis_secim_sayisi'];?>" > <input type="hidden" name="bir_defa_dogru_cavabi_buldu" id="bir_defa_dogru_cavabi_buldu" value="<?php echo $_POST['bir_defa_dogru_cavabi_buldu'];?>" > <script type="text/javascript"> var startTime = new Date(); window.onbeforeunload = function () { var endTime = new Date (); var timeSpent = (endTime - startTime)/1000; var zaman_olculen_sayfa = getFileName (); var xmlhttp; if (window.XMLHttpRequest) { xmlhttp = new XMLHttpRequest; } else { xmlhttp = new ActiveXObject ("Microsoft.XMLHTTP"); } var url = "http://localhost/tez/time.php?time=" + timeSpent +"&sayfa="+zaman_olculen_sayfa +"&baslama_zamani="+startTime +"&bitirme_zamani="+endTime; xmlhttp.open("GET", url, false); xmlhttp.send(null); } function getFileName () { var url = document.location.href; // this gets the full url url = url.substring(0,(url.indexOf("#")==-1) ? url.length : url.indexOf("#")); url = url.substring(0,(url.indexOf("?")==-1) ? url.length : url.indexOf("?")); url = url.substring(url.lastIndexOf("/")+1, url.length); return url; } </script> <h3> IF DEYİMİ </h3> <p> <b>ÖRNEK 3: </p> <table width="100%" border="0"> <tr> <td> </td> <td><textarea name="kod_yazim_alani" id="kod_yazim_alani" value="<?php echo $kod_yazim_alani?>" class="formtextarea" cols="95%" rows="10"><?php if(isset($_POST['kod_yazim_alani']))echo trim($_POST['kod_yazim_alani'])?></textarea></td> </tr> </table> <script type="text/javascript">createTextAreaWithLines('kod_yazim_alani');</script> <script type="text/javascript"> if (!document.kosul.kod_yazim_alani.value.match (/\S/)) { // Değer olarak boşluk olmayan bir karakter yok ise document.kosul.kod_yazim_alani.value = "<?php\n $not = 55;\n \n echo \"Kaldı.\";\n }\n?>"; } </script> <table width="100%" border="0"> <tr> <td width="4%" align="left"> </td> <td width="96%" align="left"><input name="kod_calistir" type="submit" value="Tüm Kodu Dene" align="center" ></td> </tr> </table> <p> </p> <p> <fieldset><legend>Seçenekler</legend> <table width="100%" border="0" align="left"> <tr> <td width="442"> <p> <input type = "radio" name = "cevap" id="c_1" value = "if (60 < $not) {" onchange = "msjYazdir(this.value);" <?php if ( $_POST['cevap'] == "if (60 < \$not) {" ) echo "checked" ?> > if (60 < $not) { </p> <p> <input type = "radio" name = "cevap" id="c_2" value = "if ($not < 60) {" onchange = "msjYazdir(this.value);" <?php if ( $_POST['cevap'] == "if (\$not < 60) {" ) echo "checked" ?> > if ($not < 60) { </p> <p> <input type = "radio" name = "cevap" id="c_3" value = "if {$not < 60} {" onchange = "msjYazdir(this.value);" <?php if ( $_POST['cevap'] == "if {\$not < 60} {" ) echo "checked" ?> > if {$not < 60} { </p> <p> <input type = "radio" name = "cevap" id="c_4" value = "if {$not =< 60} {" onchange = "msjYazdir(this.value);" <?php if ( $_POST['cevap'] == "if {\$not =< 60} {" ) echo "checked" ?> > if {$not =< 60} { </p> </td> <td width="865" align="left" ><textarea name="mesaj_kutusu" value="<?php echo $mesaj_kutusu?>" cols="30" rows="6" readonly="readonly" id="mesaj kutusu"><?php if (isset($_POST['mesaj_kutusu'])) echo trim ($_POST['mesaj_kutusu'])?></textarea></td> </tr> </table> </fieldset> <input type="button" align= "right" name="ipucu" value="İpucu Göster" onClick="ipucu_goster ();"> <p> <a href="5_kosullu_ifadeler_if_c_2_b.php"><img src="ileri.gif"alt="Sonraki Sayfa" width="80" height="40" border="0" align="right"></a> <a href="5_kosullu_ifadeler_if_c.php"><img src="geri.gif" alt="Önceki Sayfa" width="80" height="40" border="0" align="right"></a> </p> </form> <!-- </td> </tr> </table> --> </body> </html>



Reply With Quote




Bookmarks