Поиск в Поддержке

Avoid support scams. We will never ask you to call or text a phone number or share personal information. Please report suspicious activity using the “Report Abuse” option.

Learn More

TypeError: document.getelementbyid(...) is null

  • 2 ответа
  • 36 имеют эту проблему
  • 34854 просмотра
  • Последний ответ от Abhijeet Ashok Muneshwar

more options
<html>

 <head>
  <title>Port Scanner for Mozilla Firefox</title>
 </head>
 
 <body>

  <form name="my_form" id="my_form" method="post" action="#" onsubmit="return displayMessage();">
   <p align="center">URL/Domain Name/IP Address: <input type="text" size="20" name="uri" value="" placeholder="http://www.google.com" required/></p>
   <table align="center" border="1" width=100% bgcolor="#f4fff0" bordercolor="green" cellspacing="2" cellpadding="2">
    <tr>
     <td align="center">
      Start port: <input type="text" size="5" name="start_port" maxlength="5">
      End port: <input type="text" size="5" name="end_port" maxlength="5"><br>
      <input type="submit" value="Scan all ports" name="scan_all"><br>
      <input type="submit" value="Scan only open ports" name="scan_open">      
     </td>
    
    </tr>
    <tr>
     <td align="center">
      <input type="text" size="20" name="scan_tcp"><br>
      <font color="#b1b1b1">Enter port numbers separated by space. (e.g. 21 25 80)</font><br>
      <input type="submit" value="Scan TCP ports" name="scan_tcp_ports">     
     </td>
    </tr>
    <tr>
     <td align="center">
      <input type="submit" value="Scan common service ports" name="scan_common_tcp"><br>
      <input type="submit" value="Scan common Trojan ports" name="scan_common_trojan_tcp">     
     </td>
    </tr>
   </table>
  </form>
     <script type="text/javascript">
   function displayMessage()
   {
     if(document.my_form.uri.value==0)
     {
      document.write("<font color='red'><i>Please enter URL/Domain Name/IP Address.</i></font>");
      return false;
     }
     document.write("<DIV id='loading'><BR><BR><font color='#FF6600'><i>Please wait... The ports are being scanned...</i></font></DIV>");
     document.getElementById("my_form").submit();     
   }
      window.onload=function()
   {  
    document.getElementById("loading").style.display="none";  
      }  
  </script>
 </body>
</html>

I want to submit above form. But it shows me JavaScript error in Console that "TypeError: document.getelementbyid(...) is null" This error is for code : document.getElementById("my_form").submit();

I am using Firefox 24.0 and Windows 7. I have installed only 1 add-on. That is 'Firebug 1.12.3'. This code works fine for other browsers Except Firefox. Please help me to solve this problem.

Изменено cor-el

Выбранное решение

Thank you very much. I could solve this error by using 'innerHTML' instead of document.write as it is deprecated.

Прочитайте этот ответ в контексте 👍 1

Все ответы (2)

more options

It works fine for me...

Start Firefox in Safe Mode to check if one of the extensions (Firefox/Tools > Add-ons > Extensions) or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance).

To Enable SafeMode

  • You can open Firefox 4.0+ in Safe Mode by holding the Shift key when you open the Firefox desktop or Start menu shortcut.
  • Or open the Help menu and click on the Restart with Add-ons Disabled... menu item while Firefox is running.
  • Once you get the pop-up, just select "'Start in Safe Mode"

If it works in Safe Mode and in normal mode with all extensions (Tools > Add-ons > Extensions) disabled then try to find which extension is causing it by enabling one extension at a time until the problem reappears.

Close and restart Firefox after each change via "Firefox > Exit" (Windows: Firefox/File > Exit; Mac: "Firefox > Quit Firefox"; Linux: "Firefox/File > Quit")

more options

Выбранное решение

Thank you very much. I could solve this error by using 'innerHTML' instead of document.write as it is deprecated.