我需要在html表格中显示以下网址。我试图在html表中显示它。我在jquery中读取它后,它被截断了?请参阅下面的示例代码。这是我的示例代码。任何想法?
<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script type="text/javascript">
$("document").ready(function () {
var table = $("#myTable");
var url = returnUrl();
table.append("<tr><td><a href='http://" + url + "'>" + "click here" + "</a></td></tr>");
});
function returnUrl() {
var link = "myurl:8080/#/billmeterbil/sip-billmeterbil-aaaa6?_g=(refreshInterval:(display:Off,pause:!f,section:0,value:0),time:(from:now-5y,mode:quick,to:now))&_a=(filters:!((meta:(apply:!t,disabled:!f,index:mydb,key:deghiklb_Mpijkbb,negate:!f,value:'1970.1_0909_1'),query:(match:(deghiklb_Mpijkbb:(query:'1970.1_0909_1',type:phrase)))),(meta:(disabled:!f,index:mydb,key:cccc_vvvvvvvv,negate:!f,value:aaaaaaaa_v1_9),query:(match:(cccc_vvvvvvvv:(query:aaaaaaaa_v1_9,type:phrase))))),panels:!((col:7,id:sip-BSF-Socccerr-Drao-Didoryyy,row:9,size_x:6,size_y:2,type:diagramdiag),(col:7,id:'sip-BSF-Socccerr-ABBBB-Seconds-(estimated)',row:11,size_x:6,size_y:2,type:diagramdiag),(col:1,id:Introduction,row:1,size_x:12,size_y:1,type:diagramdiag),(col:1,id:Azxcvbnmn-by-Ccc-and-Status,row:2,size_x:12,size_y:3,type:diagramdiag),(col:7,id:Lineee-bb-Statest,row:13,size_x:6,size_y:3,type:diagramdiag),(col:1,id:'Test-Statest-(%25)',row:9,size_x:6,size_y:3,type:diagramdiag),(col:7,id:'soap-Kingdom-(%25)',row:16,size_x:6,size_y:3,type:diagramdiag),(col:1,id:'Projchan-Kingdom-(%25)',row:19,size_x:12,size_y:4,type:diagramdiag),(col:1,id:Overall-Test-Kingdom-%25,row:12,size_x:6,size_y:3,type:diagramdiag),(col:1,id:sip-BSF-Socccerr-CPU,row:15,size_x:6,size_y:2,type:diagramdiag),(col:1,id:sip-BSF-Socccerr-Delta-Didoryyy,row:17,size_x:6,size_y:2,type:diagramdiag),(col:1,columns:!(_source),id:All-data-Search,row:23,size_x:12,size_y:8,sort:!(Created_On,desc),type:search),(col:1,id:soap-RootRoo,row:5,size_x:6,size_y:4,type:diagramdiag),(col:7,id:sip-Projchan,row:5,size_x:6,size_y:4,type:diagramdiag)),query:(query_string:(analyze_wildcard:!t,query:'*')),title:'sip%20billmeterbil%20Demo6'))";
return link;
}
</script>
</head>
<body>
<form>
<table id="myTable">
<thead>
<tr>
<th>Url</th>
</tr>
</thead>
</table>
</form>
</body>
</html>
答案 0 :(得分:0)
尝试看看下面的“Rohit Batta”的评论
table.append('<tr><td><a href="http://' + url + '">' + 'click here' + '</a></td></tr>');
答案 1 :(得分:0)
我以这种方式工作:
$("document").ready(function () {
var table = $("#myTable");
var url = returnUrl();
table.append('<tr><td><a href='+returnUrl()+'>' + "click here" + "</a></td></tr>");
});
function returnUrl() {
var link = "myurl:8080/#/billmeterbil/sip-billmeterbil-aaaa6?_g=(refreshInterval:(display:Off,pause:!f,section:0,value:0),time:(from:now-5y,mode:quick,to:now))&_a=(filters:!((meta:(apply:!t,disabled:!f,index:mydb,key:deghiklb_Mpijkbb,negate:!f,value:'1970.1_0909_1'),query:(match:(deghiklb_Mpijkbb:(query:'1970.1_0909_1',type:phrase)))),(meta:(disabled:!f,index:mydb,key:cccc_vvvvvvvv,negate:!f,value:aaaaaaaa_v1_9),query:(match:(cccc_vvvvvvvv:(query:aaaaaaaa_v1_9,type:phrase))))),panels:!((col:7,id:sip-BSF-Socccerr-Drao-Didoryyy,row:9,size_x:6,size_y:2,type:diagramdiag),(col:7,id:'sip-BSF-Socccerr-ABBBB-Seconds-(estimated)',row:11,size_x:6,size_y:2,type:diagramdiag),(col:1,id:Introduction,row:1,size_x:12,size_y:1,type:diagramdiag),(col:1,id:Azxcvbnmn-by-Ccc-and-Status,row:2,size_x:12,size_y:3,type:diagramdiag),(col:7,id:Lineee-bb-Statest,row:13,size_x:6,size_y:3,type:diagramdiag),(col:1,id:'Test-Statest-(%25)',row:9,size_x:6,size_y:3,type:diagramdiag),(col:7,id:'soap-Kingdom-(%25)',row:16,size_x:6,size_y:3,type:diagramdiag),(col:1,id:'Projchan-Kingdom-(%25)',row:19,size_x:12,size_y:4,type:diagramdiag),(col:1,id:Overall-Test-Kingdom-%25,row:12,size_x:6,size_y:3,type:diagramdiag),(col:1,id:sip-BSF-Socccerr-CPU,row:15,size_x:6,size_y:2,type:diagramdiag),(col:1,id:sip-BSF-Socccerr-Delta-Didoryyy,row:17,size_x:6,size_y:2,type:diagramdiag),(col:1,columns:!(_source),id:All-data-Search,row:23,size_x:12,size_y:8,sort:!(Created_On,desc),type:search),(col:1,id:soap-RootRoo,row:5,size_x:6,size_y:4,type:diagramdiag),(col:7,id:sip-Projchan,row:5,size_x:6,size_y:4,type:diagramdiag)),query:(query_string:(analyze_wildcard:!t,query:'*')),title:'sip%20billmeterbil%20Demo6'))";
return encodeURIComponent("http://"+link);
}
所以你的网址中有一个"
正在打破它,所以我使用encodeURIComponent
来解决这个问题。并且还改变了'
和"
的用法。
答案 2 :(得分:-3)
您必须更改脚本代码并将'
替换为"
,反之亦然。因为,URL包含'
字符,它被视为URL的字符串结尾。
<script type="text/javascript">
$("document").ready(function () {
var table = $("#myTable");
var url = returnUrl();
table.append('<tr><td><a href="http://' + url + '">' + 'click here' + '</a></td></tr>');
});
function returnUrl() {
var link = "myurl:8080/#/billmeterbil/sip-billmeterbil-aaaa6?_g=(refreshInterval:(display:Off,pause:!f,section:0,value:0),time:(from:now-5y,mode:quick,to:now))&_a=(filters:!((meta:(apply:!t,disabled:!f,index:mydb,key:deghiklb_Mpijkbb,negate:!f,value:'1970.1_0909_1'),query:(match:(deghiklb_Mpijkbb:(query:'1970.1_0909_1',type:phrase)))),(meta:(disabled:!f,index:mydb,key:cccc_vvvvvvvv,negate:!f,value:aaaaaaaa_v1_9),query:(match:(cccc_vvvvvvvv:(query:aaaaaaaa_v1_9,type:phrase))))),panels:!((col:7,id:sip-BSF-Socccerr-Drao-Didoryyy,row:9,size_x:6,size_y:2,type:diagramdiag),(col:7,id:'sip-BSF-Socccerr-ABBBB-Seconds-(estimated)',row:11,size_x:6,size_y:2,type:diagramdiag),(col:1,id:Introduction,row:1,size_x:12,size_y:1,type:diagramdiag),(col:1,id:Azxcvbnmn-by-Ccc-and-Status,row:2,size_x:12,size_y:3,type:diagramdiag),(col:7,id:Lineee-bb-Statest,row:13,size_x:6,size_y:3,type:diagramdiag),(col:1,id:'Test-Statest-(%25)',row:9,size_x:6,size_y:3,type:diagramdiag),(col:7,id:'soap-Kingdom-(%25)',row:16,size_x:6,size_y:3,type:diagramdiag),(col:1,id:'Projchan-Kingdom-(%25)',row:19,size_x:12,size_y:4,type:diagramdiag),(col:1,id:Overall-Test-Kingdom-%25,row:12,size_x:6,size_y:3,type:diagramdiag),(col:1,id:sip-BSF-Socccerr-CPU,row:15,size_x:6,size_y:2,type:diagramdiag),(col:1,id:sip-BSF-Socccerr-Delta-Didoryyy,row:17,size_x:6,size_y:2,type:diagramdiag),(col:1,columns:!(_source),id:All-data-Search,row:23,size_x:12,size_y:8,sort:!(Created_On,desc),type:search),(col:1,id:soap-RootRoo,row:5,size_x:6,size_y:4,type:diagramdiag),(col:7,id:sip-Projchan,row:5,size_x:6,size_y:4,type:diagramdiag)),query:(query_string:(analyze_wildcard:!t,query:'*')),title:'sip%20billmeterbil%20Demo6'))";
return link;
}
</script>
此外,您应该将脚本标记位置更改为底部以获得更好的性能。以下链接可以帮助您理解这一点。
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<!DOCTYPE html>
<html lang="en">
<head>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
</head>
<body>
<form>
<table id="myTable">
<thead>
<tr>
<th>Url</th>
</tr>
</thead>
</table>
</form>
<script type="text/javascript">
$("document").ready(function () {
var table = $("#myTable");
var url = returnUrl();
table.append('<tr><td><a href="http://' + url + '">' + 'click here' + '</a></td></tr>');
});
function returnUrl() {
var link = "myurl:8080/#/billmeterbil/sip-billmeterbil-aaaa6?_g=(refreshInterval:(display:Off,pause:!f,section:0,value:0),time:(from:now-5y,mode:quick,to:now))&_a=(filters:!((meta:(apply:!t,disabled:!f,index:mydb,key:deghiklb_Mpijkbb,negate:!f,value:'1970.1_0909_1'),query:(match:(deghiklb_Mpijkbb:(query:'1970.1_0909_1',type:phrase)))),(meta:(disabled:!f,index:mydb,key:cccc_vvvvvvvv,negate:!f,value:aaaaaaaa_v1_9),query:(match:(cccc_vvvvvvvv:(query:aaaaaaaa_v1_9,type:phrase))))),panels:!((col:7,id:sip-BSF-Socccerr-Drao-Didoryyy,row:9,size_x:6,size_y:2,type:diagramdiag),(col:7,id:'sip-BSF-Socccerr-ABBBB-Seconds-(estimated)',row:11,size_x:6,size_y:2,type:diagramdiag),(col:1,id:Introduction,row:1,size_x:12,size_y:1,type:diagramdiag),(col:1,id:Azxcvbnmn-by-Ccc-and-Status,row:2,size_x:12,size_y:3,type:diagramdiag),(col:7,id:Lineee-bb-Statest,row:13,size_x:6,size_y:3,type:diagramdiag),(col:1,id:'Test-Statest-(%25)',row:9,size_x:6,size_y:3,type:diagramdiag),(col:7,id:'soap-Kingdom-(%25)',row:16,size_x:6,size_y:3,type:diagramdiag),(col:1,id:'Projchan-Kingdom-(%25)',row:19,size_x:12,size_y:4,type:diagramdiag),(col:1,id:Overall-Test-Kingdom-%25,row:12,size_x:6,size_y:3,type:diagramdiag),(col:1,id:sip-BSF-Socccerr-CPU,row:15,size_x:6,size_y:2,type:diagramdiag),(col:1,id:sip-BSF-Socccerr-Delta-Didoryyy,row:17,size_x:6,size_y:2,type:diagramdiag),(col:1,columns:!(_source),id:All-data-Search,row:23,size_x:12,size_y:8,sort:!(Created_On,desc),type:search),(col:1,id:soap-RootRoo,row:5,size_x:6,size_y:4,type:diagramdiag),(col:7,id:sip-Projchan,row:5,size_x:6,size_y:4,type:diagramdiag)),query:(query_string:(analyze_wildcard:!t,query:'*')),title:'sip%20billmeterbil%20Demo6'))";
return link;
}
</script>
</body>
</html>
&#13;