本文档指导 WordPress 开发者如何利用浏览器工具诊断 JavaScript 错误或冲突,以解决交互功能问题,如菜单、元框或媒体按钮失效。通过分步流程,帮助开发者定位错误并有效提交支持请求。
define('SCRIPT_DEBUG', true);If you’re experiencing issues with your interactive functionality this may be due to JavaScript errors or conflicts. For example, your flyout menus may be broken, your metaboxes don’t drag, or your add media buttons aren’t working. In order to formulate your support request it helps the team to know what the JavaScript error is.
This guide will show you how to diagnose JavaScript issues in different browsers.
Different browsers often implement parts of JavaScript differently. To make sure that this is a JavaScript error, and not a browser error, first of all try opening your site in another browser.
Make note of any browsers you are experiencing the error in. You can use this information when you are making a support request.
You need to turn on script debugging. Open wp-config.php and add the following line before “That’s all, stop editing! Happy blogging”.
define('SCRIPT_DEBUG', true);
Check to see if you are still having an issue.
Cmd-Option-J (Mac) or Ctrl-Shift-J (Windows, Linux, Chrome OS), or navigate to View -> Developer -> Developer Tools in the menu.Cmd-Option-K (Mac) or Ctrl-Shift-K (Windows, Linux, Chrome OS), or navigate to Web Development -> Web Console in the menu.Safari -> Preferences. Click on the Advanced tab, then check Show Develop Menu in menu bar. Then, in the new Develop menu, navigate to Show JavaScript Console.Tools -> Advanced -> Error Console in the menu.Often, the text of the error will already be visible in the console. It may look similar to this:

The image above shows the error to be in jquery.js on line 2, however remember to copy the whole stack information! Just saying what line is less helpful that showing context.
If no errors are displayed, reload the page; many errors occur only when the page is first loaded.
Now that you have diagnosed your error, you should make your support forum request. Go to the troubleshooting forum.
If your problem is with a specific theme or plugin, you can access their dedicated support forum by visiting https://wordpress.org/support/plugin/PLUGINNAME or https://wordpress.org/support/theme/THEMENAME.
Please include the below information:
SCRIPT_DEBUG fixed the error or not