2016-09-23 122 views
0
<!DOCTYPE html> 
<html> 
<head> 
<script> 
//if i put window.location= "index.php" here not inside js function it worked but I need it to be inside a function 
function newLoad() { 
    window.location= "index.php" 
} 
</script> 
</head> 
<body> 

<input type="button" value="press here" onclick="newLoad()"> 

</body> 
</html> 

任何想法我怎么能让它在JavaScript函数内工作?window.location不工作里面的js功能

+3

定义_not working_ !! –

+0

没有指向index.php –

+0

你的代码应该运行,那么有什么不同? – epascarello

回答

0

您的代码有效。 Howether,你不需要使用JavaScript。

<a href="index.php"> 
    <button>press here</button> 
</a>