Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [PHP][HTML][AJAX] nie dziala w firefox
calebos
post
Post #1





Grupa: Zarejestrowani
Postów: 104
Pomógł: 3
Dołączył: 22.02.2008

Ostrzeżenie: (0%)
-----


Czesc

Czemu mi to nie chce smigac w Firefox 2/3?
Idea : onclick -> php -> mysql

W IE dziala ok
Poprawnie wyswietla alert z typem przegladarki w ff i ie.

  1. <?php /* sample4_1.php */ ?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
  3. "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  4. <html xmlns="http://www.w3.org/1999/xhtml">
  5. <title>Sample 4_1</title>
  6. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  7. <link rel="stylesheet" type="text/css" href="style.css" />
  8. <script type="text/javascript" >
  9. //functions.js
  10. //Create a boolean variable to check for a valid Internet Explorer instance.
  11. var xmlhttp = false;
  12. //Check if we are using IE.
  13. try {
  14. //If the javascript version is greater than 5.
  15. xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  16. alert ("dont use IE5!!!");
  17.  
  18. } catch (e) {
  19. //If not, then use the older active x object.
  20. try {
  21. //If we are using IE.
  22. xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  23. alert ("dont use IE!!!");
  24. } catch (E) {
  25. //Else we must be using a non-IE browser.
  26. xmlhttp = false;
  27. }
  28. }
  29. //If we are using a non-IE browser, create a javascript instance of the object.
  30. if (!xmlhttp && typeof XMLHttpRequest != 'undefined') {
  31. xmlhttp = new XMLHttpRequest();
  32. alert ("Not IE!!!");
  33.  
  34. }
  35. //Function to run a word grabber script.
  36. function grabword (theelement){
  37. //If there is nothing in the box, run Ajax to populate it.
  38. if (document.getElementById(theelement).innerHTML.length == 0){
  39. //Change the background color.
  40. document.getElementById(theelement).style.background = "#CCCCCC";
  41. serverPage = "/wris/wordgrabber.php";
  42. var obj = document.getElementById(theelement);
  43. xmlhttp.open("POST", serverPage);
  44. xmlhttp.onreadystatechange = function() {
  45. if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {
  46. obj.innerHTML = xmlhttp.responseText;
  47. }
  48. }
  49. xmlhttp.send(null);
  50. } else {
  51. //Change the background color.
  52. document.getElementById(theelement).style.background = "#FFFFFF";
  53. //If the box is already populated, clear it.
  54. document.getElementById(theelement).innerHTML = "";
  55. }
  56. }
  57. </head>
  58. <body>4
  59. <?php
  60. for ($i = 1; $i < 9; $i++)
  61. {
  62. ?>
  63.  
  64. <div class="dborder" id="dborder<?=$i?>" onclick="grabword(this.id)"></div>
  65. <br/>
  66. <?php }
  67. ?>
  68. </body>
  69. </html>
Go to the top of the page
+Quote Post

Posty w temacie


Reply to this topicStart new topic
2 Użytkowników czyta ten temat (2 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 31.08.2025 - 17:37