关于“筑巢”的问题使用Javascript [英] Question on "nesting" Javascript

查看:57
本文介绍了关于“筑巢”的问题使用Javascript的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好。


我试图让这个页面工作使用

< script src =" url / test.php?webid = ADSasdfasdwerqy34"> //你明白我的意思


在test.php我这样做:


var test =''hello world。'' ;

document.write(测试);

当然这当我调用第一页时有效,它实际显示:你好

世界。


但我现在想要一些与众不同的东西。我想要一个提醒。


var test ="< SCRIPT>

window.alert(''hello world'');

< / SCRIPT" ;;

document.write(test);


这绝对没有。你能帮我吗?我需要这个工作!


Thx


米歇尔


解决方案



Michel写道:

大家好。

我想让这个页面工作使用
< script src =" url / test.php?webid = ADSasdfasdwerqy34"> //你明白我的观点在test.php中我做了类似的事情:

var test =''hello world。';
document.write (测试);

当然这当我调用第一页时有效,它实际上显示:你好世界。

但我现在想要一些与众不同的东西。我想要一个警报。

var test ="< SCRIPT>
window.alert(''hello world'');
< / SCRIPT" ;;
document.write(test);




替换上面只是:


window.alert(" hello world");


" Michel" < no@spam.please>写道:

但我现在想要一些与众不同的东西。我想要一个警报。

var test ="< SCRIPT>
window.alert(''hello world'');
< / SCRIPT" ;;
document.write(test);




我会假设你有一些理由要添加一个新的脚本元素

而不仅仅是它当前的内容。


我在上面看到两个错误。

首先,Javascript字符串文字不能包含换行符。

更改为:


var test ="< SCRIPT> \ n" +

" window.alert(''hello world''); \ n" +

" < / SCRIPT";


如果你想要的字符串与你想要的完全相同。


其次,你错过了一个 ;>"在< / SCRIPT之后。

如果上述代码包含在HTML页面中的

脚本元素中,则可能会出现第三个潜在错误,因为内容

首次出现< /时结束了这样的结果。因此,总的来说,将行更改为:


var test ="< SCRIPT> \ n" +

" window.alert(''hello world''); \ n" +

" < \ / SCRIPT>" ;;


/ L

-

Lasse Reichstein Nielsen - lr*@hotpop.com

DHTML死亡颜色:< URL:http://www.infimum.dk/HTML/rasterTriangleDOM .html>

''没有判断的信仰只会降低精神神圣。''




" web .dev" <我们******** @ gmail.com>在消息中写道

news:11 ********************* @ g49g2000cwa.googlegro ups.com ...


Michel写道:

大家好。

我试图让这个页面使用
< script src =" ?URL / test.php的webid = ADSasdfasdwerqy34"> //你明白我的观点在test.php中我做了类似的事情:

var test =''hello world。';
document.write (测试);

当然这当我调用第一页时有效,它实际显示:
你好世界。

但我现在想要一些与众不同的东西。我想要一个警报。

var test ="< SCRIPT>
window.alert(''hello world'');
< / SCRIPT" ;;
document.write(test);



将以上内容替换为:

window.alert(" hello world");




你这么好笑。


任何人都更认真?


Hi everyone.

I am trying to get this page to work using
<script src="url/test.php?webid=ADSasdfasdwerqy34"> //you get my point

in test.php I do something like this:

var test=''hello world.'';
document.write(test);
of course this works when I call the first page, it actually displays: hello
world.

But I now want something different. I want an alert coming up.

var test="<SCRIPT>
window.alert(''hello world'');
</SCRIPT";
document.write(test);

This does absolutely nothing. Can you help me please? I need this to work!

Thx

Michel


解决方案


Michel wrote:

Hi everyone.

I am trying to get this page to work using
<script src="url/test.php?webid=ADSasdfasdwerqy34"> //you get my point

in test.php I do something like this:

var test=''hello world.'';
document.write(test);
of course this works when I call the first page, it actually displays: hello
world.

But I now want something different. I want an alert coming up.

var test="<SCRIPT>
window.alert(''hello world'');
</SCRIPT";
document.write(test);



replace above with just:

window.alert("hello world");


"Michel" <no@spam.please> writes:

But I now want something different. I want an alert coming up.

var test="<SCRIPT>
window.alert(''hello world'');
</SCRIPT";
document.write(test);



I''ll assume you have some reason for adding a new script element
instead of just its content to the current one.

I see two errors in the above.
First of all, a Javascript string literal cannot contain newlines.
Change it to:

var test="<SCRIPT>\n"+
" window.alert(''hello world'');\n"+
" </SCRIPT";

if you want exactly the same string as you seem to intend.

Second, you are missing an ">" after the "</SCRIPT".
A third potential error can occour if the above code is contained in a
script element in an HTML page, since the content of such ends at the
first occurence of "</". So, in total, change the line to:

var test="<SCRIPT>\n"+
" window.alert(''hello world'');\n"+
" <\/SCRIPT>";

/L
--
Lasse Reichstein Nielsen - lr*@hotpop.com
DHTML Death Colors: <URL:http://www.infimum.dk/HTML/rasterTriangleDOM.html>
''Faith without judgement merely degrades the spirit divine.''



"web.dev" <we********@gmail.com> wrote in message
news:11*********************@g49g2000cwa.googlegro ups.com...


Michel wrote:

Hi everyone.

I am trying to get this page to work using
<script src="url/test.php?webid=ADSasdfasdwerqy34"> //you get my point

in test.php I do something like this:

var test=''hello world.'';
document.write(test);
of course this works when I call the first page, it actually displays: hello world.

But I now want something different. I want an alert coming up.

var test="<SCRIPT>
window.alert(''hello world'');
</SCRIPT";
document.write(test);



replace above with just:

window.alert("hello world");



O you so funny.

Anyone more serious?


这篇关于关于“筑巢”的问题使用Javascript的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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