按钮未引导到所需位置

时间:2019-10-11 15:25:00

标签: php html

在我的标签内,我有一个echo语句,其中包含以下行:

mylist_a <- list(aa = structure(list(D1 = c(52L, 103L, 15L, 3L, 1L, 0L), 
    D2 = c(41L, 111L, 12L, 2L, 1L, 0L), D3 = c(55L, 104L, 16L, 
    0L, 0L, 2L)), class = "data.frame", row.names = c("a", "b", 
"c", "d", "e", "f")))

mylist_b <- list(aa = structure(list(D1 = c(0.68659264, 0.02358574, 1, 1, 
1, 1), D2 = c(1, 0.0007992743, 1, 1, 1, 1), D3 = c(1, 0.3253237, 
1, 1, 1, 1)), class = "data.frame", row.names = c("a", "b", "c", 
"d", "e", "f")))

我的理解是,这样做应该使t带您进入onclick参数中的任何链接。但是,当我单击按钮时,按钮却没有任何作用

2 个答案:

答案 0 :(得分:0)

第一个问题:您在onclick内有style个事件,这是错误的。这些是2个单独的属性。仅使用onclick

第二个问题:所有字符串(内部/外部)的引号都相同。您必须对内部参数使用不同的方法。

有效解决方案:

<button onclick="window.location.href='https://www.google.com'">Go to Google</button>

顺便说一句。我宁愿使用<a>而不是<button/>

答案 1 :(得分:0)

这应该是您要寻找的

编辑:已编辑以适合php echo,

function gotoPage(link){
window.location.href = "" +link;
}
$link = "hoi";
echo "<button onclick='gotoPage(".$link.")'>Go to Google</button>";