/    Sign up×
Community /Pin to ProfileBookmark

.js file is messing up

When i do <script language=”JavaScript” type=”text/javascript” src=”Scripts.js”>…… (theres a function for getting mouseposition in the .js)
Alot of other scripts stop working and says “An object is expected” on every function call.
Also i would like to know what you call those files so i know what i have to search for in the future.

to post a comment
JavaScript

7 Comments(s)

Copy linkTweet thisAlerts:
@FangMay 17.2005 — Scripts.js is not being loaded, possibly incorrect path.
Copy linkTweet thisAlerts:
@scragarMay 17.2005 — if you have a unix server be sure to check the case as well.
Copy linkTweet thisAlerts:
@DrakilorauthorMay 18.2005 — i run on my own computer (windows) and im pretty sure the path is correct since it´s in the same folder.

I forgot to mention that the functions that won´t work is the one´s in the html-document, not in the .js (wich is working fine).
Copy linkTweet thisAlerts:
@FangMay 18.2005 — Do you have a page we can look at?
Copy linkTweet thisAlerts:
@DrakilorauthorMay 19.2005 — http://drakilor.atspace.com/ Thats when it works good, i just removed the "src="Scripts.js"" in the JavaScript tag.

Heres Scripts.js:

[CODE]// Set Netscape up to run the "captureMousePosition" function whenever
// the mouse is moved. For Internet Explorer and Netscape 6, you can capture
// the movement a little easier.
if (document.layers) { // Netscape
document.captureEvents(Event.MOUSEMOVE);
document.onmousemove = captureMousePosition;
} else if (document.all) { // Internet Explorer
document.onmousemove = captureMousePosition;
} else if (document.getElementById) { // Netcsape 6
document.onmousemove = captureMousePosition;
}
// Global variables
xMousePos = 0; // Horizontal position of the mouse on the screen
yMousePos = 0; // Vertical position of the mouse on the screen
xMousePosMax = 0; // Width of the page
yMousePosMax = 0; // Height of the page

function captureMousePosition(e) {
if (document.layers) {
// When the page scrolls in Netscape, the event's mouse position
// reflects the absolute position on the screen. innerHight/Width
// is the position from the top/left of the screen that the user is
// looking at. pageX/YOffset is the amount that the user has
// scrolled into the page. So the values will be in relation to
// each other as the total offsets into the page, no matter if
// the user has scrolled or not.
xMousePos = e.pageX;
yMousePos = e.pageY;
xMousePosMax = window.innerWidth+window.pageXOffset;
yMousePosMax = window.innerHeight+window.pageYOffset;
} else if (document.all) {
// When the page scrolls in IE, the event's mouse position
// reflects the position from the top/left of the screen the
// user is looking at. scrollLeft/Top is the amount the user
// has scrolled into the page. clientWidth/Height is the height/
// width of the current page the user is looking at. So, to be
// consistent with Netscape (above), add the scroll offsets to
// both so we end up with an absolute value on the page, no
// matter if the user has scrolled or not.
xMousePos = window.event.x+document.body.scrollLeft;
yMousePos = window.event.y+document.body.scrollTop;
xMousePosMax = document.body.clientWidth+document.body.scrollLeft;
yMousePosMax = document.body.clientHeight+document.body.scrollTop;
} else if (document.getElementById) {
// Netscape 6 behaves the same as Netscape 4 in this regard
xMousePos = e.pageX;
yMousePos = e.pageY;
xMousePosMax = window.innerWidth+window.pageXOffset;
yMousePosMax = window.innerHeight+window.pageYOffset;
}
}[/CODE]
Copy linkTweet thisAlerts:
@scragarMay 19.2005 — wait, you have both src="" and content(on the same script tag)? Then that's your problem, by specify a source and contents to the script tag the source takes priority and the contents are ignored.

just split it into two tags and your sorted:

&lt;script type="text/javascript" src="Scripts.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript"&gt;&lt;!--
...........
//--&gt;&lt;/script&gt;
Copy linkTweet thisAlerts:
@DrakilorauthorMay 20.2005 — wait, you have both src="" and content(on the same script tag)? Then that's your problem, by specify a source and contents to the script tag the source takes priority and the contents are ignored.

just split it into two tags and your sorted:

&lt;script type="text/javascript" src="Scripts.js"&gt;&lt;/script&gt;
&lt;script type="text/javascript"&gt;&lt;!--
...........
//--&gt;&lt;/script&gt;
[/QUOTE]



Aha, now it works. Thank you wery much. =)
×

Success!

Help @Drakilor spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.18,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...