0

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();

}

11
  • 6
    The </script> in the button defenition is not supposed to be there. Commented Jul 23, 2014 at 19:21
  • Modify <button type="button" onclick="clickie();"</script>">Next</button> to <button type="button" onclick="clickie();">Next</button> Commented Jul 23, 2014 at 19:32
  • I have that... it just doesnt grab the function. Commented Jul 23, 2014 at 19:35
  • Is fair_functions.js in the same directory as the html page? Commented Jul 23, 2014 at 19:54
  • 1
    try running it in Chrome and take a look at this: developer.chrome.com/devtools/index it will make your life much easier. similar tools are available in most browsers. Commented Jul 23, 2014 at 21:23

2 Answers 2

1

Try wrapping the script in the body and just before the </body> tag e.g.

...

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

</body>

</html>
Sign up to request clarification or add additional context in comments.

2 Comments

Arent you supposed to tell it the source in the head so it knows where the function is coming from?
No, in the head leave only jQuery/jQueryUI if you use it, every other script put just before the </body> tag.
0

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.

2 Comments

reading the discussion above, I suspect you using badly suited tools (like windows, notepad, IE, etc.) and you had a hidden ".js.txt" ending messing up the path or something like that.
I'm using sublime text.. but there wasnt any hidden file extensions. I checked almost everything I could.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.