Solved

moving javascript to file causes error

Posted on 2015-01-23
4
137 Views
Last Modified: 2015-01-23
I have some javascript included in my html head and I think it runs on the page load. It is something like
$(function() {
;
;
});

if I move it to a file and then call it with:
<script type="text/javascript" src="/scripts/capture.js"></script>
it reports an error. How do I format the function if I move it to a file?
0
Comment
Question by:garysamuels
  • 2
4 Comments
 
LVL 10

Expert Comment

by:10023
ID: 40567163
You broke the link to the     /scripts/capture.js   file when you move the the html file that includes the path in  the head script
0
 

Author Comment

by:garysamuels
ID: 40567181
I cut the javascript from the html header and pasted it into a file. Now in the header I'm calling <script type="text/javascript" src="/scripts/capture.js"></script> which is good because there is also a <base href="http://www.mydomain.com" />.
0
 
LVL 38

Accepted Solution

by:
Tom Beck earned 500 total points
ID: 40567411
Not much to go on. Is the error because of the doc ready function you posted or is it coming from deep inside the script?

Here's a dumb question. Does this markup, <script type="text/javascript" src="/scripts/capture.js"></script>, occur on the page AFTER your jQuery library include? If not, that would cause an error.
0
 

Author Closing Comment

by:garysamuels
ID: 40567571
Not a dumb question at all. YES, I placed the call before loading the JQuery library. So I guess I get the dummy award today.
Thanks
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

This article discusses the difference between strict equality operator and equality operator in JavaScript. The Need: Because JavaScript performs an implicit type conversion when performing comparisons, we have to take this into account when wri…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

8 Experts available now in Live!

Get 1:1 Help Now