使用javascript移动到另一个php页面

使用javascript移动到另一个php页面,javascript,html,Javascript,Html,我试图在点击li goes to javascript函数后从一个页面移动到另一个页面,该函数请求转到另一个页面 以下是我的js代码: function profile(usertype){ alert(usertype); window.location="comehere.php"; } index.php页面代码: <!DOCTYPE html> <html> <head> <script src="style.js"></sc

我试图在点击li goes to javascript函数后从一个页面移动到另一个页面,该函数请求转到另一个页面

以下是我的js代码:

function profile(usertype){
 alert(usertype);
 window.location="comehere.php";
}
index.php页面代码:

<!DOCTYPE html>
<html>
<head>
 <script src="style.js"></script>
 </head>
<body>
 <div id="Menu-bar" >
   <ul>
  <li style="position:absolute;left:430px;Top:0;"><a 
   href="javascript:profile('Admin');" class="active" id="report-print">
     <img src="images/users.png"></a></li>
   </div>
 </ul>
 </body>

comehre.php页面:

<!DOCTYPE html>
<html>
 <head>
<h1>HALLOOOOOOOOOOOO  </h1>
</head>

单击
li
,我只会收到警报,不会移动到另一个页面,为什么?

我在这里进行了测试,效果很好。看起来你在javascript中输入了“comehere”,当必须是“comehre”时-没有“e”

应该是
window.location.href
我已经尝试过了,但没有成功:\!它是否没有移动到指定的页面?或者它会重新定位,只是没有定位到正确的页面?
alert()
在某些情况下会停止JavaScript进程。你应该寻找一个不同的解决方案。您可以改用
console.log()
吗?@Akintunde007设置
window.location
是有效的,这只是设置基础href属性的较短方法