简体   繁体   中英

javascript alert box cannot popup in Eclipse when running tomcat

The alert is written as script in html file

<script type="text/javascript">
      $(document).ready(function(){
        alert("test");
      });
</script>

When opening the file in browser , alert box prompts as desired. However, when I tried to run on localhost:8080 with TomCat inside Eclipse , it does not pop any alert box anymore.

I have checked Eclipse preference, under WebService->Popup Dialogue, it does not hide any pop-ups. Does anyone know if the setting is hidden somewhere or I am doing something else wrong? Thank you!

检查jquery.js文件是否与html文件位于同一文件夹中,并确保已在html文件中导入相同的.js文件。

First case might be your alert box is blocked by popup blocker. Just check whether you have installed and activated any of popup blocker.
Another case may be that resource path is not fulfilled properly. Just check whether your .js lib and images are present in proper directory.
have a look on directory structure below ( it worked for me and even I faced the same problem once :) )

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM