本文介绍了innerHTML和JavaScript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 大家好, 我正在尝试使用客户端生成客户端javascript javascript。我正在使用innerHTML这样做。 示例: 假设我有变量叫做文本。我用一个字符串 来填充它:< script type =" text / javascript">一些JavaScript< / script> 然后我执行以下操作: document.getElementById(''someid'')。innerHTML = text; 为什么这不起作用? greetz BjornHi all,I''m trying to generate client-side javascript with client-sidejavascript. I''m doing this using innerHTML.Example:Let''s say i have variable called text. I fill this with a stringsomething like: <script type="text/javascript">Some JavaScript</script>And then i do the following:document.getElementById(''someid'').innerHTML = text;Why isn''t this working?greetz Bjorn推荐答案 这听起来很奇怪,一切都可以通过使用一些函数和 参数来完成,是吗?确定你在做什么? 无论如何,尝试以上,我只是在IE,FF和Opera上测试过... var s = document.createElement(" script"); s.type =" text / javascript" ;; s.text =" alert(' 'jonas'');" ;; document.body.appendChild(s); - " Invente,Tente! ! Fa?aucódigofefieniente" (eu) Jonas Raoni Soares Silva ----------------------- ---- jonasraoni at gmail dot com http:/ /www.jsfromhell.comIt sounds strange, everything can be made by using some functions andarguments, are you sure of what you''re doing?Anyway, try the above, I just tested on IE, FF and Opera...var s = document.createElement("script");s.type = "text/javascript";s.text = "alert(''jonas'');";document.body.appendChild(s);--"Invente, Tente!!! Fa?a um código eficiente" (eu)Jonas Raoni Soares Silva---------------------------jonasraoni at gmail dot com http://www.jsfromhell.com 随着这些UA的众多版本,这可能意味着任何事情/> - 或者没有。 var s = document.createElement(" script"); s.type =" text / javascript" ;; s.text =" alert(''jonas'');" ;; document.body.appendChild(s);With the numerous version of those UAs around, that can mean anything-- or nothing. var s = document.createElement("script"); s.type = "text/javascript"; s.text = "alert(''jonas'');"; document.body.appendChild(s); 不工作可靠。 < URL:http://pointedears.de/scripts/test/whatami#inference> PointedEarsDoes not work reliably.<URL:http://pointedears.de/scripts/test/whatami#inference>PointedEars JavaScript是邪恶的,应该是在网站上做的最后一件事, 一切都已经完成工作......这可能会解决部分 问题... - Invente,Tente !!! Fa?aucódigofefieniente" (eu) Jonas Raoni Soares Silva ----------------------- ---- jonasraoni at gmail dot com http:/ /www.jsfromhell.comJavaScript is evil and should be the last thing to be done on a site,after everything is already working... This might solve part of theproblems...--"Invente, Tente!!! Fa?a um código eficiente" (eu)Jonas Raoni Soares Silva---------------------------jonasraoni at gmail dot com http://www.jsfromhell.com 这篇关于innerHTML和JavaScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 08-22 16:41