这是我从以下位置获取代码的地方: https://www.w3schools.com/php/php_ajax_livesearch.asp
if ($hint=="") {
$hint="<a href='" .
$z->item(0)->childNodes->item(0)->nodeValue .
"' target='_blank'>" .
$y->item(0)->childNodes->item(0)->nodeValue . "</a>";
} else {
$hint=$hint . "<br /><a href='" .
$z->item(0)->childNodes->item(0)->nodeValue .
"' target='_blank'>" .
$y->item(0)->childNodes->item(0)->nodeValue . "</a>";
}
假设我点击显示的结果后,我的网站网址是“ www.example.com”,我进入的网址是“ https://www.example.com/www.example.com/something.html”
我该怎么做?
答案 0 :(得分:0)
只需添加HTTP协议即可避免此问题。
if ($hint=="") {
$hint="<a href='https://" . $z->item(0)->childNodes->item(0)->nodeValue . "' target='_blank'>" .
$y->item(0)->childNodes->item(0)->nodeValue . "</a>";
} else {
$hint=$hint . "<br /><a href='https://" . $z->item(0)->childNodes->item(0)->nodeValue . "' target='_blank'>" .
$y->item(0)->childNodes->item(0)->nodeValue . "</a>";
}
您也可以使其动态化,而不必硬编码为https://