简体   繁体   中英

Cannot call external javascript function

I cannot call the function clickie from the file fair_functions.js

html page

<head>

    <script type="text/javascript" src="fair_functions.js"></script>

</head>

<body>

    <button type="button" onclick="clickie();"</script>">Next</button>

</body>

fair_functions.js

function clickie () {

alert("asdfsadfsdf");
window.open('test (2).html','_blank');
self.close();

}

Try wrapping the script in the body and just before the </body> tag eg

...

<script src="fair_functions.js"></script>

</body>

</html>

Thanks everyone for your help, I just created a new file and copied in my functions one at a time and tested each time. It seems to be working now, not sure what happened in the old file.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM