SSI与javacript - 语法问题。 [英] SSI with javacript - syntax problem.

查看:89
本文介绍了SSI与javacript - 语法问题。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

HI!我正在尝试使用

JavaScript动态地将内容添加到Div标签中。它加载页面但添加了几个字符。脚本是

以下。


< script language =" JavaScript">

document.write('' < div id = DivExample>"<! - #include

virtual =" /Include_Pages_Asp/Main.htm" - >< / div>'');

< / script>

添加的字符就在Main.htm页面结束之后。他们

如下。


'');


我在IE中也遇到此JavaScript错误


行:48

字符:106

错误:未终止的字符串常量。


由于页面确实完全加载,我怀疑它的语法问题很小但是

我只是不知道是什么。


有人可以告诉我是什么我做错了吗?


-

提前致谢:)


Paul

解决方案

Paul写道:

HI!我正在尝试使用
JavaScript动态地将内容添加到Div标签中。它加载页面但添加了几个字符。脚本在下面。

< script language =" JavaScript">
document.write(''< div id = DivExample>"< ;! - #include
virtual =" /Include_Pages_Asp/Main.htm" - >< / div>'');
< / script>

添加的字符就在Main.htm页面结束之后。
如下:

'');

我也在IE中收到此JavaScript错误

线路:48
字符:106
错误:未终止的字符串常量。




这应该是一个提示。


计数上面的document.write调用中的's和's。


我看到两个但是,奇怪的是(双关语),三个。三个人通常会在某个地方导致未终止的字符串。 "打开字符串但没有关闭

。你正在纠错。


我怀疑是第一个不应该在那里。


干杯

理查德。


HI!谢谢你的回应。它仍然无法正常工作。我在源代码中看到

查看它写了一行然后停止。


我被告知包含需要在服务器上发生,这个

包含指令正在客户端写出,到时候它太晚了
包括在内。


这是链接。
http://www.webcandesign.com/111/main_test_newnew .asp


如何加载页面?


Paul


" RF" < @ invalid.com>在消息中写道

news:dL ****************** @ news-server.bigpond.net.au ...

保罗写道:

嗨!我正在尝试使用
JavaScript动态地将内容添加到Div标签中。它加载页面但添加了几个字符。脚本在下面。

< script language =" JavaScript">
document.write(''< div id = DivExample>"< ;! - #include
virtual =" /Include_Pages_Asp/Main.htm" - >< / div>'');
< / script>

添加的字符就在Main.htm页面结束之后。


它们

如下所示。

'');
行:48
字符:106
错误:未终止的字符串常量。



这应该是一个提示。

计算上面的document.write调用中的's和's。

我看到两个's但是,很奇怪(双关语),三个。三个人通常会在某个地方造成无端的字符串。 "打开字符串但没有关闭
。你是纠错的摆布。

我怀疑第一个不应该在那里。

干杯
理查德。





保罗写道:

HI!谢谢你的回应。它仍然无法正常工作。我在源视图中看到它写了一行然后停止。

我被告知包含需要在服务器上发生,这个
include指令正在写出来客户在哪个时候太迟了包括。

这是链接。
http://www.webcandesign.com/111/main_test_newnew.asp

如何加载页面然后?

Paul

" rf" < @ invalid.com>在消息中写道
新闻:dL ****************** @ news-server.bigpond.net.au ...

Paul写道:

HI!我正在尝试使用
JavaScript动态地将内容添加到Div标签中。它加载页面但添加了几个字符。脚本在下面。

< script language =" JavaScript">
document.write(''< div id = DivExample>"< ;! - #include
virtual =" /Include_Pages_Asp/Main.htm" - >< / div>'');
< / script>

添加的字符就在Main.htm页面结束之后。


它们

如下所示。

'');
行:48
字符:106
错误:未终止的字符串常量。



这应该是一个提示。

计算上面的document.write调用中的's和's。

我看到两个's但是,很奇怪(双关语),三个。三个人通常会在某个地方造成无端的字符串。 "打开字符串但没有关闭
。你是纠错的摆布。

我怀疑第一个不应该在那里。

干杯
理查德。




Hello Paul,

如果您正在尝试使用javascript进行SSI,那么你将会解决所有问题

错误。它被称为服务器端包含(SSI)是有原因的。这就是它在服务器端发生的
。你可以尝试做客户端

包括,但请相信我,这会很快变得凌乱。以下是一些

一般解决方案:


对于ASP页面:


<! - #include virtual =" filename" - >



<! - #include file =" filename" - >


对于PHP页面:

require(" filename");



include(" filename" );


对于SHTML页面:

<! - #include virtual =" filename" - >



<! - #include file =" filename" - >


希望这会有所帮助。


HI! I am trying to dynamically add content into Div tags with the use of
JavaScript. it loads the page but adds a few characters. the script is
below.

<script language="JavaScript">
document.write(''<div id=DivExample>"<!--#include
virtual="/Include_Pages_Asp/Main.htm" --></div>'');
</script>

The characters that are added is right after the end of Main.htm page. they
are as follows.

'');

I also get this JavaScript error in IE

Line: 48
Char:106
Error:Unterminated string constant.

Since the page does load fully I suspect that Its a small syntax problem but
I just don''t know what.

can someone tell me what I am doing wrong?

--
Thanks in advance :)

Paul

解决方案

Paul wrote:

HI! I am trying to dynamically add content into Div tags with the use of
JavaScript. it loads the page but adds a few characters. the script is
below.

<script language="JavaScript">
document.write(''<div id=DivExample>"<!--#include
virtual="/Include_Pages_Asp/Main.htm" --></div>'');
</script>

The characters that are added is right after the end of Main.htm page. they are as follows.

'');

I also get this JavaScript error in IE

Line: 48
Char:106
Error:Unterminated string constant.



That should be a hint.

Count the ''s and the "s in the above document.write call.

I see two ''s but, oddly (pun intended), three "s. Three "s would usually
cause an unterminated string somewhere. " to open the string but no closing
". You are at the mercy of error correction.

I suspect the first " should not be there.

Cheers
Richard.


HI! thanks for responding. It still does not work. I see in source
view that it writes a one line then stops.

I being told that Includes need to happen on the server, this
include directive is being written out on the client by which time it''s too
late to include.

Here is the link.
http://www.webcandesign.com/111/main_test_newnew.asp

How do load the page then?

Paul

"rf" <@invalid.com> wrote in message
news:dL******************@news-server.bigpond.net.au...

Paul wrote:

HI! I am trying to dynamically add content into Div tags with the use of
JavaScript. it loads the page but adds a few characters. the script is
below.

<script language="JavaScript">
document.write(''<div id=DivExample>"<!--#include
virtual="/Include_Pages_Asp/Main.htm" --></div>'');
</script>

The characters that are added is right after the end of Main.htm page.


they

are as follows.

'');

I also get this JavaScript error in IE

Line: 48
Char:106
Error:Unterminated string constant.



That should be a hint.

Count the ''s and the "s in the above document.write call.

I see two ''s but, oddly (pun intended), three "s. Three "s would usually
cause an unterminated string somewhere. " to open the string but no
closing
". You are at the mercy of error correction.

I suspect the first " should not be there.

Cheers
Richard.




Paul wrote:

HI! thanks for responding. It still does not work. I see in source
view that it writes a one line then stops.

I being told that Includes need to happen on the server, this
include directive is being written out on the client by which time it''s too
late to include.

Here is the link.
http://www.webcandesign.com/111/main_test_newnew.asp

How do load the page then?

Paul

"rf" <@invalid.com> wrote in message
news:dL******************@news-server.bigpond.net.au...

Paul wrote:

HI! I am trying to dynamically add content into Div tags with the use of
JavaScript. it loads the page but adds a few characters. the script is
below.

<script language="JavaScript">
document.write(''<div id=DivExample>"<!--#include
virtual="/Include_Pages_Asp/Main.htm" --></div>'');
</script>

The characters that are added is right after the end of Main.htm page.


they

are as follows.

'');

I also get this JavaScript error in IE

Line: 48
Char:106
Error:Unterminated string constant.



That should be a hint.

Count the ''s and the "s in the above document.write call.

I see two ''s but, oddly (pun intended), three "s. Three "s would usually
cause an unterminated string somewhere. " to open the string but no
closing
". You are at the mercy of error correction.

I suspect the first " should not be there.

Cheers
Richard.



Hello Paul,

If you''re trying to do SSI with javascript, you''re going about it all
wrong. It''s called Server Side Includes (SSI) for a reason. That being
that it happens on the server side. You can attempt to do Client Side
Includes, but believe me, that will get messy real fast. Here are some
general solutions:

For an ASP page:

<!--#include virtual="filename"-->
or
<!--#include file ="filename"-->

For a PHP page:
require("filename");
or
include("filename");

For a SHTML page:
<!--#include virtual="filename"-->
or
<!--#include file ="filename"-->

Hope this helps.


这篇关于SSI与javacript - 语法问题。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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