admin管理员组文章数量:1279181
onclick="var searchb = jQuery('#'+searchBoxLinkId).value;
var searchlink= window.location.protocol + '//' + window.location.hostname+'/Dave2/Pages/FAQSearch.aspx?category='+category+'&k='+searchb;
window.location = searchlink;" href="javascript: {}">
I have added this line of code to my javascript/html but it gives me the error Unterminated string constant
however I cannot see where the problem is.
I have to do it this way as I am doing something in sharepoint and it seems like this way is the only way it will work
onclick="var searchb = jQuery('#'+searchBoxLinkId).value;
var searchlink= window.location.protocol + '//' + window.location.hostname+'/Dave2/Pages/FAQSearch.aspx?category='+category+'&k='+searchb;
window.location = searchlink;" href="javascript: {}">
I have added this line of code to my javascript/html but it gives me the error Unterminated string constant
however I cannot see where the problem is.
I have to do it this way as I am doing something in sharepoint and it seems like this way is the only way it will work
- you have some heavy typos in your code, check the double quotes – john Smith Commented Sep 9, 2014 at 10:56
- Look at the colors in the code above, and see if you can't spot it, it has something to do with the quotes. – adeneo Commented Sep 9, 2014 at 10:56
- because I am doing this in a sharepoint display template and as I have created my own function, it won't be defined in the ctx, so can't be run by just putting the function name – user3956534 Commented Sep 9, 2014 at 11:10
- if you know how to do this in sharepoint please tell me – user3956534 Commented Sep 9, 2014 at 11:11
2 Answers
Reset to default 5You do not set the searchBoxLinkId
and category
variables.
We assume some existing HTML (such as the snippet below) will set the two variables. In the code below, you can enter some variable into input
and category
is set to 11111
. When you click on a tag, you redirect to that address.
<html>
<head>
<title></title>
<script type="text/javascript" src="jquery.min.js"></script>
<script type="text/javascript">
var category=11111;
</script>
</head>
<body>
<input type="text" id="searchBoxLinkId"/>
<a onclick="var searchb = jQuery('#searchBoxLinkId').val(); var searchlink= window.location.protocol + '//' + window.location.hostname+'/Dave2/Pages/FAQSearch.aspx?category='+category+'&k='+searchb;window.location.href = searchlink;" href="#">eee</a>
</body>
You can use matching pairs of single or double quotation marks. Double quotation marks can be contained within strings surrounded by single quotation marks, and single quotation marks can be contained within strings surrounded by double quotation marks.
本文标签: htmlUnterminated string constant javascriptStack Overflow
版权声明:本文标题:html - Unterminated string constant javascript - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741245562a2364806.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论