简体   繁体   English

如何获取到JavaScript的jsp页面ID?

[英]how to get the jsp page id to the javascript?

我正在使用jsp,在那我使用了带有“ id”的搜索框,我想将该ID读取到javascript文件中,但是document.getelementbyid()无法正常工作...

Java/JSP runs at server machine and produces a HTML/CSS/JS page. Java / JSP在服务器计算机上运行,​​并生成HTML / CSS / JS页面。 Javascript runs at the client side and knows nothing about Java/JSP/whatever code which runs at the server side. Javascript在客户端运行,而对在服务器端运行的Java / JSP /任何代码一无所知。 Open the page in webbrowser, rightclick and choose View Source . 在webbrowser中打开页面,右键单击并选择View Source You see, no single line of Java/JSP code (if it has done its job right). 您会看到,没有一行Java / JSP代码(如果正确完成了它的工作)。 Also see this article . 另请参阅本文

Your problem is more in the Javascript/HTML corner. 您的问题更多在Javascript / HTML角落。 Since it's unclear what exactly you mean with "not working" (you're more talking in end-user perspective than in real developer's perspective), I suggest to get yourself through some basic tutorials first to get the concepts and the basic terminology right so that you can ask better questions here. 由于尚不清楚“不起作用”的确切含义(与最终开发人员相比,您在谈论的是终端用户而不是真正的开发人员),因此,我建议您先阅读一些基础教程,以正确理解概念和基本术语,以便您可以在这里提出更好的问题。 There are decent basic tutorials/references at w3schools.com: Javascript and HTML DOM . 在w3schools.com上有不错的基本教程/参考资料: JavascriptHTML DOM

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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