Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/363.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript代码问题与;和';_Javascript - Fatal编程技术网

Javascript代码问题与;和';

Javascript代码问题与;和';,javascript,Javascript,通常我们可以使用var a=“”但我需要在同一行代码中包含2个以上的”,如下所示: var status = "<a href='javascript:window.open('atendimento.php','hhchat','top=70,left=70,width=480,height=450,status=no,location=no,statusbar=no');void(0);'><img src='img/atendimento.png' width='160'

通常我们可以使用
var a=“”但我需要在同一行代码中包含2个以上的
,如下所示:

var status = "<a href='javascript:window.open('atendimento.php','hhchat','top=70,left=70,width=480,height=450,status=no,location=no,statusbar=no');void(0);'><img src='img/atendimento.png' width='160' border='0' /></a>";
var status=”“;
所以问题是它在这里开始和结束行代码:
'javascript:window.open('

我需要它一直持续到行尾。怎么做呢?

使用
并将其转义:

var status = "<a href='javascript:window.open(\"atendimento.php\",\"hhchat\", ...
var status=“您不会遇到这种问题。

使用
并将其转义:

var status = "<a href='javascript:window.open(\"atendimento.php\",\"hhchat\", ...

var status=“您不会遇到这种问题。

您需要转义您的字符:

var status = "<a href=\"javascript:window.open('atendimento.php','hhchat','top= ...

var status=“

您需要转义您的字符:

var status = "<a href=\"javascript:window.open('atendimento.php','hhchat','top= ...

var status=“

使用反斜杠转义字符串中的引号:

"<a href='javascript:window.open(\"atendimento.php\" ....

“使用反斜杠转义字符串中的引号:

"<a href='javascript:window.open(\"atendimento.php\" ....

“在href之后使用转义字符,如下所示=

var status = "<a href=\"javascript:window.open('atendimento.php','hhchat','top=70,left=70,width=480,height=450,status=no,location=no,statusbar=no');void(0);\"><img  src='img/atendimento.png' width='160' border='0' /></a>"; 
var status=”“;

在href之后使用转义字符,如下所示=

var status = "<a href=\"javascript:window.open('atendimento.php','hhchat','top=70,left=70,width=480,height=450,status=no,location=no,statusbar=no');void(0);\"><img  src='img/atendimento.png' width='160' border='0' /></a>"; 
var status=”“;
交换“和”,然后转义“

var status=“交换”和“然后转义”


var status=“我将避免尝试将HTML生成为字符串。如果这是在浏览器代码中,请使用DOM函数创建HTML元素(
var a=document.createElement('a');a.href=“javascript:…”;
)。在服务器端,使用一个模板系统来为您处理报价。还有一些便宜的模板系统在客户端也能很好地工作-我个人最喜欢的是。我会避免尝试将HTML生成为字符串。如果这是在浏览器代码中,请使用DOM函数来创建HTML元素(
var a=document.createElement('a');a.href)=“javascript:…”;
).在服务器端,使用一个模板系统为您处理报价。还有一些便宜的模板系统在客户端也能很好地工作-我个人最喜欢的是。撇开意识形态不谈,我发现网站的某些部分很好地解释了Javascript的基础知识。例如,这是一个MDN页面,它解释了如何使用Javascript转义:这就是这对于刚刚学习Javascript的人来说有点冗长。撇开意识形态不谈,我发现网站的某些部分非常好地解释了Javascript的基础知识。例如,这是一个MDN页面,它解释了Javascript中的转义:对于刚刚学习Javascript的人来说,这有点冗长。点击事件在点击的情况下不起作用吗在新选项卡中打开(例如ctr+单击)?如果在新选项卡中单击打开(例如ctr+单击),单击事件不起作用吗?