Click to See Complete Forum and Search --> : conflicting javascripts
pyritechips
05-15-2003, 10:37 AM
Hello:
I am a new member- first post here and I have a minor problem.
I am running a conveyorbelt slide show from dynamic drive and also a fadein slideshow. Alone, they both work fine but will not work together. I have read about the problem HERE (http://www.javascriptkit.com/javatutors/eventaction.shtml) but the solution doesn't work.
I tried putting the first scripts (the one that wont work) onload into the body tag as suggested but the seconf script (the one that does work) has only 1 onload line and it is part of a conditional line: if (ie4||dom) window.onload=startit
Pardon my question but I am a HTML newbie and dont't know javascript at all.
<body onload="if(ie||dom){startit();} otherFunctionName();">
brendandonhue
05-15-2003, 03:35 PM
<offtopic>
Hey PC, why no posts at TSG in over a week?
</offtopic>
havik
05-15-2003, 03:38 PM
This will work as well
function loadFuncs() {
// in case this function is outside the scope of these variables
ie = put definition here
dom = put definition here
if(ie||dom)
startit()
otherfunction();
//you can add ask many as you wish
}
<body onload="loadFuncs()">
Havik
pyritechips
05-19-2003, 03:49 AM
Thx for the suggestions ppl but I couldn't get it to work. Since I don't really know any JS and am only cut & pasting small scripts it's hard to know if I am coding it right.
I haven't had a chance to play with it much, as my W2K screwed up big time on me. I don't have it fixed yet but luckily I have a dual platform and am now on W98 until W2K is fixed.
Very good forum BTW.
:)
Hi B:
Actually I haven't posted in over a month there. I left for political reasons. Instead of banging my head uselessly against the wall I am spending my time coding. My new page is growing quite large and is turning into a HTML database! Wish I knew how to handle variables so I didn't have to repeat the same lines of code hundreds of times.
TTYL
New problem related to the same webpage:
I can't get target="_blank" windows to open to a specific size:confused:
brendandonhue
05-19-2003, 04:51 AM
You could put the lines of code into .JS files like we did for your A-Z menu of links for your other page, and call it with
<script type="text/javascript" src="file.js"></script>
To get it to open in a new window with a certain size, try this
<a href="window.open(URL, name,width=X,height=X)">Window</a>
Brendandonhue, that's wrong. You have no quotes. Like this:
<a href="default.htm" onClick="window.open('http://w3.org/','The W3C','width=400,height=400'); return false;">This page will go to default.htm if the user does not have JavaScript enabled. If JavaScript is enabled, it will open the W3C Web site in a new window with the width and height at 400 pixels each.</a>
Referring to the original problem, though. Havik, you did have a syntax error in your method which was possibly the method used by pyritechips. Your *correct* method would look like this:
<script type="text/javascript">
<!--
function checkToStart(){
if(ie||dom) startit(); /* if IE or Document Object Model exists (that is, document.getElementById) run the function startit() */
else // if it is not IE or the DOM does not exist for this browser
return; // stop the function and exit
}
// -->
</script>
<body onload="checkToStart();">
That is assuming that you have var ie = document.all and var dom = document.getElementById declared before your function. As such:
var ie = document.all;
var dom = document.getElementById;
function checkToStart(){
..... Etcetera, just make sure your variables are declared before the function.
Also, if you would like to run a different function if the browser is not Internet Explorer (IE) or does not have the DOM (Document Object Model), e.g., Netscape 2, you can replace the line: return; with the name of the function followed by to parenthesis and a semi-colon. Example: instead of return; replace that line with: runMyFunction();. The semi-colon at the end is not necessary, but it is a good idea to always use semi-colons at the end of your commands. As long you don't put a semi-colon after a statement such as if. Example: if(this=="that"){; will return a syntax error, but: var jon = "Hello, my name is Jon."; will not cause a syntax error.
Hope that helped.... Whew! :D
Jona
havik
05-19-2003, 06:02 PM
Havik, you did have a syntax error in your method which was possibly the method used by pyritechips.
K, thanks for correcting my error, :D
Havik
lol, Any time, man. Any time! :D j/k