我想传递一个javascript函数的参数,它是一个字符串。这个javascript函数是鼠标悬停的一个提示框。
我使用的字符串是这样的:
边缘整理:横幅的每一面/边缘(1/2“到2")都是折叠和胶粘的(特殊乙烯基溶液)或热压。这是最常见和最好的完成选项。 缝制完成:横幅的每一面/边(1“到2")都折叠在背面,用白线缝制/缝制。这不是一个常见的选项,因为可以在横幅上看到线程。
现在,在鼠标悬停的后备箱中,必须显示上述给定的文本,因为它与段落断点一起显示在上面。但是当我在函数中作为参数传递上面的参数时,加上一些反斜杠以识别一些标点符号,直到给出未终止字符串的javascript错误.
我是这样做的:
onMouseover="showhint('Hemmed Finish\: Every side/edge \(1/2\'\' to 2\'\'\) of the banner are folded and glued \(special vinyl solution\) or heat pressed. This is the most common and best finish option.Stitched Finish\: Every side/edge \(1\'\' to 2\'\'\) of the banner are folded in the back and stitched/sewed with white thread. This is not a common option as thread can be seen on the banner', this, event, '250px')"请你帮我纠正这个问题.
发布于 2010-05-28 12:49:14
好吧,我有个解决办法:
<element onMouseover="showhint('<p>Hemmed Finish: Every side/edge (1/2" to 2") of the banner is folded and glued (special vinyl solution) or heat pressed. This is the most common and best finish option.</p><p>Stitched Finish: Every side/edge (1" to 2") of the banner is folded in the back and stitched/sewed with white thread. This is not a common option as thread can be seen on the banner</p>', this, event, '250px')" />您必须使用"转义XML风格的引号。
参见一个工作示例这里。
发布于 2010-05-28 12:42:13
检查一下这个:
onMouseover="showhint('Hemmed Finish: Every side/edge (1/2\'\' to 2\'\') of the banner are folded and glued (special vinyl solution) or heat pressed. This is the most common and best finish option.Stitched Finish: Every side/edge (1\'\' to 2\'\') of the banner are folded in the back and stitched/sewed with white thread. This is not a common option as thread can be seen on the banner', this, event, '250px')"您不需要转义:括号如下(
<script type="text/javascript">
<!--//
function alert2()
{
alert ("Don't forget the curly "+
"brackets - \nThey are essential!");
}
//-->
</script>发布于 2010-05-28 12:47:35
我在这里看到了两个潜在的问题。
因此,您应该如何定义hintbox字符串:
hintbox = "Hemmed Finish: Every side/edge (1/2\" to 2\") of the banner are folded and glued (special vinyl solution) or heat pressed. This is the most common and best finish option.\n\nStitched Finish: Every side/edge (1\" to 2\") of the banner are folded in the back and stitched/sewed with white thread. This is not a common option as thread can be seen on the banner.";这通常被称为“转义字符串”,一个快速的Google应该会给你更多的关于上面图片的信息。
编程愉快!
https://stackoverflow.com/questions/2928979
复制相似问题