innerHTML和JavaScript [英] innerHTML and JavaScript
问题描述
大家好,
我正在尝试使用客户端生成客户端javascript
javascript。我正在使用innerHTML这样做。
示例:
假设我有变量叫做文本。我用一个字符串
来填充它:< script type =" text / javascript">一些JavaScript< / script>
然后我执行以下操作:
document.getElementById(''someid'')。innerHTML = text;
为什么这不起作用?
greetz Bjorn
Hi all,
I''m trying to generate client-side javascript with client-side
javascript. I''m doing this using innerHTML.
Example:
Let''s say i have variable called text. I fill this with a string
something 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
推荐答案
>我正在尝试使用客户端
> I''m trying to generate client-side javascript with client-side
javascript生成客户端javascript。我正在使用innerHTML这样做。
javascript. I''m doing this using innerHTML.
这听起来很奇怪,一切都可以通过使用一些函数和
参数来完成,是吗?确定你在做什么?
无论如何,尝试以上,我只是在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.com
It sounds strange, everything can be made by using some functions and
arguments, 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
Jonas Raoni写道:
Jonas Raoni wrote:
我正在尝试使用客户端
javascript生成客户端javascript。我正在使用innerHTML来做这件事。
这听起来很奇怪,一切都可以通过使用一些函数和参数来制作,你确定你在做什么吗?
>无论如何,试试上面的内容,我只是在IE,FF和Opera上测试过...
I''m trying to generate client-side javascript with client-side
javascript. I''m doing this using innerHTML.
It sounds strange, everything can be made by using some functions
and arguments, are you sure of what you''re doing?
Anyway, try the above, I just tested on IE, FF and Opera...
随着这些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>
PointedEars
Does not work reliably.
<URL:http://pointedears.de/scripts/test/whatami#inference>
PointedEars
托马斯''PointedEars''Lahn escreveu:
Thomas ''PointedEars'' Lahn escreveu:
随着这些UA的众多版本,这可能意味着什么 - 或者什么也没有。
以这种方式创建JavaScript听起来很奇怪...总有另外一个
出路做事......
不能可靠地工作。
With the numerous version of those UAs around, that can mean anything
-- or nothing.
Creating JavaScript that way sounds strange... There''s always another
way out to do things...
Does not work reliably.
JavaScript是邪恶的,应该是在网站上做的最后一件事,
一切都已经完成工作......这可能会解决部分
问题...
-
Invente,Tente !!! Fa?aucódigofefieniente" (eu)
Jonas Raoni Soares Silva
----------------------- ----
jonasraoni at gmail dot com
http:/ /www.jsfromhell.com
JavaScript is evil and should be the last thing to be done on a site,
after everything is already working... This might solve part of the
problems...
--
"Invente, Tente!!! Fa?a um código eficiente" (eu)
Jonas Raoni Soares Silva
---------------------------
jonasraoni at gmail dot com
http://www.jsfromhell.com
这篇关于innerHTML和JavaScript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!