<script type = "text/javascript">
function DisplayDashboard(Work Package)
{
var Src = '';
if (Work Package=='Google')
{
Src =<a href="https://www.google.com">Link</a>;
}
else if(Work Package=='Bing')
{
Src = <a href ="https://www.bing.com">Link</a>;
}
return <'+Work Package+'>;
}
</script>
我要做的是查找Google或Bing,然后在Javascript中显示正确的链接。但由于某种原因,它无法正常工作。
答案 0 :(得分:1)
Work Package
在字符string
值必须由''
或""
Src
尝试
function DisplayDashboard(WorkPackage) {
var Src = '';
if (WorkPackage == 'Google') {
Src = '<a href="https://www.google.com">Link</a>';
} else if (WorkPackage == 'Bing') {
Src = '<a href ="https://www.bing.com">Link</a>';
}
return Src;
}
答案 1 :(得分:0)
将Work Package
替换为WorkPackage
。删除空格。
function DisplayDashboard(WorkPackage)
{
var Src = '';
if (WorkPackage=='Google')
Src ='<a href="https://www.google.com">Link</a>';
else if(WorkPackage=='Bing')
Src = '<a href ="https://www.bing.com">Link</a>';
return src;
}
答案 2 :(得分:0)
我猜你需要用双引号括起HTML来形成一个有效的字符串吗?
如:
Src = "<a href="https://www.google.com">Link</a>";