I have a html input button which calling this function
<button class="Go" onClick="go();" disabled><div class="inner first">Nah...Not Yet</div></button>
But this script I created in another javascript which code like this name "test.js"
function go()
{
window.location.href = 'https://google.com';
}
How should I input the scriptype for the input button in order to call this function?
Vini.g.fer
12k19 gold badges66 silver badges100 bronze badges
-
No need for the semicolon in the onclick.Andrew Li– Andrew Li2016年05月28日 14:55:05 +00:00Commented May 28, 2016 at 14:55
1 Answer 1
You should add a tag in your html, and all will be fine
<script type="text/javascript" src="test.js">
Sign up to request clarification or add additional context in comments.
2 Comments
user2422414
Do you know any way to hide this ? for example. if i view page source. people able to see my test.js and download it. how i going prevent them?
Nicolas M
If you want to hide the javascript inclusion, you have to do it serverside. It depends of your server language (if any). In Java, for instance, it could be
<%@include file="test.js" %>default