如何在Javascript函数中添加HTML? [英] How can I add HTML inside a Javascript function?

查看:64
本文介绍了如何在Javascript函数中添加HTML?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,


我是JS的新手,我正在尝试将一些HTML添加到JS函数中。因此,当调用脚本以及HTML时,将调用


有一些类型的嵌入机制,类似于在带有脚本标记的html页面中嵌入JS

。 (这就是我在这个

的情况下做的事情)


这甚至可能吗?


.. ..(不起作用)

< script>

function alertuser(){

alert(" FOO FOO");

< html>< input type =" file"名称= QUOT; file.1中"的tabindex = QUOT 1 QUOT;> < / html>

}

< / script>

....


非常感谢任何帮助!

谢谢!

解决方案

2005年6月10日04 :28,VictorG写道:


[snip]

是否有某种类型的嵌入机制,类似于嵌入JS的反向
在带有脚本标签的html页面中。




在组常见问题解答中搜索DynWrite。


[snip]


迈克


-

Michael Winter

替换.invalid ;与.uk通过电子邮件回复。





VictorG写道:

你好,
我是JS的新手,我正在尝试将一些HTML添加到JS函数中。所以当调用脚本以及HTML时会调用它。是否有某种类型的嵌入机制,与在脚本标记的html页面中嵌入JS相反。 (这就是我在这个案例中所做的事情)

这甚至可能吗?

...(不起作用)
<脚本>
function alertuser(){
alert(" FOO FOO");
< html>< input type =" file"名称= QUOT; file.1中"的tabindex = QUOT 1 QUOT;> < / html>
}
< / script>




在页面上设置输入的位置,就像这样。 ..


< div id =''daPlace''>< / div>


然后使用


< script>

function alertuser(){

alert(" FOO FOO");

- - > str =''< input type =" file"名称= QUOT; file.1中" tabindex =" 1">'';

- > document.getElementById(''daPlace'')。innerHTML = str;

}

< / script>


我是JS的超级初学者:我今天没有在

之前写过任何JavaScript,但感谢在线教程和参考手册我能够

来做这件事: http://members.tripod。 com / MaasInfo / New / 2005.6.13a.html

From:" Razzbar" < gl *** @ potatoradio.f2s.com>
< div id =''daPlace''>< / div>
... document.getElementById(''daPlace'')。innerHTML = str;




我试过类似的东西,但它没有工作。请有人请

关注该网址并查看来源并告诉我我做错了什么?


您如何看待我所做的其他事情一切正常(在

NetScape,这是我在这里唯一可以访问的支持JavaScript的浏览器)?

使用该语言的第一天还不错?


Hello,

I am new to JS and am trying to add some HTML into a JS function. So
that when called the script as well as the HTML will be invoked. Is
there some type of embed mechanism, sort of the reverse of embedding JS
in an html page with the script tag. (which is what I am doing in this
case)

Is this even possible?

....(does not work)
<script>
function alertuser() {
alert("FOO FOO");
<html><input type="file" name="file.1" tabindex="1"> </html>
}
</script>
....

Any help will be greatly appreciated!
Thanks!

解决方案

On 10/06/2005 04:28, VictorG wrote:

[snip]

Is there some type of embed mechanism, sort of the reverse of embedding JS
in an html page with the script tag.



Search for DynWrite in the group FAQ.

[snip]

Mike

--
Michael Winter
Replace ".invalid" with ".uk" to reply by e-mail.




VictorG wrote:

Hello,

I am new to JS and am trying to add some HTML into a JS function. So
that when called the script as well as the HTML will be invoked. Is
there some type of embed mechanism, sort of the reverse of embedding JS
in an html page with the script tag. (which is what I am doing in this
case)

Is this even possible?

...(does not work)
<script>
function alertuser() {
alert("FOO FOO");
<html><input type="file" name="file.1" tabindex="1"> </html>
}
</script>



Make some place on the page for the input to go, like this...

<div id = ''daPlace''></div>

Then use

<script>
function alertuser() {
alert("FOO FOO");
--> str = ''<input type="file" name="file.1" tabindex="1">'';
--> document.getElementById(''daPlace'').innerHTML = str;
}
</script>


I''m a super-beginner at J.S.: I never wrote any JavaScript before
today, but thanks to an online tutorial and reference manual I was able
to make this: http://members.tripod.com/MaasInfo/New/2005.6.13a.html

From: "Razzbar" <gl***@potatoradio.f2s.com>
<div id = ''daPlace''></div> ... document.getElementById(''daPlace'').innerHTML = str;



I tried something like that, but it didn''t work. Would somebody please
follow that URL and look at the source and tell me what I did wrong?

And how do you like the rest of what I did, which all works fine (in
NetScape, the only JavaScript-enabled browser I have access to here)?
Not bad for first day with the language?


这篇关于如何在Javascript函数中添加HTML?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆