Script works in IE, but not in Firefox

Please support our JavaScript / DHTML / AJAX advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
Thread Solved

Join Date: Jul 2008
Posts: 14
Reputation: chellethecat is an unknown quantity at this point 
Solved Threads: 0
chellethecat chellethecat is offline Offline
Newbie Poster

Script works in IE, but not in Firefox

 
0
  #1
Jul 15th, 2008
I decided to try and redo a site I'd had active ages ago and while looking over things to see what needed to be fixed, tweaked, and just in general redone I discovered that while viewing the site in IE everything works just as it should, but in Firefox the scrolling script doesn't seem to be working.

I didn't write the original piece of code, and so I'm kind of stumped as to how to fix it to work in Firefox. I do know the problem is somewhere in this chunk of code however. Any help on this would be greatly appreciated.

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <script language="JavaScript" SRC="dynlayer.js"></SCRIPT>
  2. <script language="JavaScript" SRC="miniscroll.js"></SCRIPT>
  3.  
  4. <script language="JavaScript">
  5.  
  6. <!--
  7. function init() {
  8. DynLayerInit()
  9. myscroll = new MiniScroll(scrollWindow,scrollContent)
  10. }
  11. //-->
  12.  
  13.  
  14. </SCRIPT>
  15. <STYLE TYPE="text/css">
  16. <!--
  17. #scrollWindowDiv {position:absolute; left:0; top:5; width:400; height:250; clip:rect(0,400,250,0);}
  18. #scrollContentDiv {position:absolute; left:0; top:5; width:400;}
  19. #scrollbtnDiv {position:absolute; left:400; top:5; width:30;}-->
  20. </STYLE>
  21.  
  22. <script language="JavaScript">
  23.  
  24. <!--
  25. preloadwh1 = new Image();
  26. preloadwh1.src = "up.gif";
  27. preloadwh2 = new Image();
  28. preloadwh2.src = "down.gif";
  29. preloadlogo = new Image();
  30. preloadlogo.src = "logo.jpg";// -->
  31. </script>
  32. </HEAD>
  33. <body onLoad="init()" text="#000000" vlink="#6699FF" link="#6699FF" alink="#000000" bgcolor="#FFFFFF" topmargin="10" leftmargin="0" marginwidth="0" marginheight="0">
  34. <DIV ID="scrollWindowDiv">
  35. <DIV ID="scrollContentDiv">
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 315
Reputation: Thirusha is an unknown quantity at this point 
Solved Threads: 50
Thirusha's Avatar
Thirusha Thirusha is offline Offline
Posting Whiz

Re: Script works in IE, but not in Firefox

 
0
  #2
Jul 15th, 2008
Have u tried using firefox's firebug?

I copied the code u provided and it doesnt work because DynLayerInit is undefined, i suspect it is in the dynlayer.js file. which u havent provided.

Please provide the other js files as well, it would help alot.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 14
Reputation: chellethecat is an unknown quantity at this point 
Solved Threads: 0
chellethecat chellethecat is offline Offline
Newbie Poster

Re: Script works in IE, but not in Firefox

 
0
  #3
Jul 15th, 2008
ACK! Sorry, I forgot completely about those... There are two .js files that are supposed to work together to create the scrolling effect. The first is the miniscroll.js file which I don't think there is a problem with from what I can tell. Then there is the dynlayer.js file, which looking at I've found a problematic block (and quite possibly the one responsible for the malfunction) that I don't know how to edit or change. I've attached both of the files, but below is what I believe might be the problem.

JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. // BrowserCheck Object
  2. function BrowserCheck() {
  3. var b = navigator.appName
  4. if (b=="Netscape") this.b = "ns"
  5. else if (b=="Microsoft Internet Explorer") this.b = "ie"
  6. else this.b = b
  7. this.version = navigator.appVersion
  8. this.v = parseInt(this.version)
  9. this.ns = (this.b=="ns" && this.v>=4)
  10. this.ns4 = (this.b=="ns" && this.v==4)
  11. this.ns5 = (this.b=="ns" && this.v==5)
  12. this.ie = (this.b=="ie" && this.v>=4)
  13. this.ie4 = (this.version.indexOf('MSIE 4')>0)
  14. this.ie5 = (this.version.indexOf('MSIE 5')>0)
  15. this.min = (this.ns||this.ie)
  16. }
  17. is = new BrowserCheck()
Attached Files
File Type: js miniscroll.js (1.5 KB, 7 views)
File Type: js dynlayer.js (7.9 KB, 6 views)
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 315
Reputation: Thirusha is an unknown quantity at this point 
Solved Threads: 50
Thirusha's Avatar
Thirusha Thirusha is offline Offline
Posting Whiz

Re: Script works in IE, but not in Firefox

 
0
  #4
Jul 16th, 2008
The problem is that in firefox it is not finding the div tags in the body of your file.
The function that has the problem is located in the dynlayer.js file
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. function DynLayerInit(nestref) {
  2. if (!DynLayer.set) DynLayer.set = true
  3. if (is.ns) {
  4. if (nestref) ref = eval('document.'+nestref+'.document')
  5. else {nestref = ''; ref = document;}
  6.  
  7. for (var i=0; i<document.getElementsByTagName("div").length; i++) {
  8. var divname = document.getElementsByTagName("div")[i].id
  9. var index = divname.indexOf("Div")
  10. if (index > 0) {
  11. eval(divname.substr(0,index)+' = new DynLayer("'+divname+'")')
  12. }
  13.  
  14. }
  15. if (DynLayer.refArray.i < DynLayer.refArray.length) {
  16. DynLayerInit(DynLayer.refArray[DynLayer.refArray.i++])
  17. }
  18. }
  19. else if (is.ie) {
  20. for (var i=0; i<document.all.tags("DIV").length; i++) {
  21. var divname = document.all.tags("DIV")[i].id
  22. var index = divname.indexOf("Div")
  23. if (index > 0) {
  24. eval(divname.substr(0,index)+' = new DynLayer("'+divname+'")')
  25. }
  26. }
  27. }
  28. return true
  29. }

U can replace that function with this one, i hope it will work for u.
Last edited by Thirusha; Jul 16th, 2008 at 4:41 am.
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 348
Reputation: Troy III will become famous soon enough Troy III will become famous soon enough 
Solved Threads: 42
Troy III's Avatar
Troy III Troy III is offline Offline
Posting Whiz

Re: Script works in IE, but not in Firefox

 
0
  #5
Jul 16th, 2008
Please try:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <!--
  2. function init() {
  3. DynLayerInit()
  4. myscroll = new MiniScroll("scrollWindowDiv", "scrollContentDiv")
  5. }
  6. //-->

Regards
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 14
Reputation: chellethecat is an unknown quantity at this point 
Solved Threads: 0
chellethecat chellethecat is offline Offline
Newbie Poster

Re: Script works in IE, but not in Firefox

 
0
  #6
Jul 16th, 2008
Thirusha, I tried what you suggested however I didn't notice a change - in IE or Firefox.

Originally Posted by Troy III View Post
Please try:
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. <!--
  2. function init() {
  3. DynLayerInit()
  4. myscroll = new MiniScroll("scrollWindowDiv", "scrollContentDiv")
  5. }
  6. //-->

Regards
Sorry if this sounds like a stupid question, but where in the file should this code be placed? As I stated, I did not write the code in the first place (and I am actually, very limited in my knowledge of JS when it comes to writing code).
Reply With Quote Quick reply to this message  
Join Date: Jun 2008
Posts: 348
Reputation: Troy III will become famous soon enough Troy III will become famous soon enough 
Solved Threads: 42
Troy III's Avatar
Troy III Troy III is offline Offline
Posting Whiz

Re: Script works in IE, but not in Firefox

 
0
  #7
Jul 17th, 2008
Sorry, I thought you knew.
-Simply replace your existing init function with this one.

(It is located in the head of your document, right after your inclusion of miniscroll and dylayer external script files, and before your style definitions, that is between them two in the header of your main html document).

Cheers.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 14
Reputation: chellethecat is an unknown quantity at this point 
Solved Threads: 0
chellethecat chellethecat is offline Offline
Newbie Poster

Re: Script works in IE, but not in Firefox

 
0
  #8
Jul 24th, 2008
Oiy... I don't know how I didn't understand where you meant that to go...

Okay, I changed that on one of the pages but it didn't appear to have made any difference to the behavior. What's more, is that after making that change, it no longer works in IE.

Just to make sure that I'm not just a great big schmuck... this is after all - almost ten year old code I'm trying to get to work... I've included the URL for the site I'm trying to make work.

http://is.rt-games.com/index2.html

I left the code you had me change on the first page (message.html)
All other pages reached by the menu have the code as it was before.
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 315
Reputation: Thirusha is an unknown quantity at this point 
Solved Threads: 50
Thirusha's Avatar
Thirusha Thirusha is offline Offline
Posting Whiz

Re: Script works in IE, but not in Firefox

 
0
  #9
Jul 24th, 2008
In the miniscroll.js replace the following lines
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. this.contentHeight = (is.ns)? this.content.doc.height : this.content.elm.scrollHeight
  2. this.contentWidth = (is.ns)? this.content.doc.width : this.content.elm.scrollWidth
with this
JavaScript / DHTML / AJAX Syntax (Toggle Plain Text)
  1. this.contentHeight = (is.ns)? this.content.scrollHeight : this.content.scrollHeight
  2. this.contentWidth = (is.ns)? this.content.scrollWidth : this.content.scrollWidth

I tried to test it on my side with some of your code from the site, and no error is shown.
Reply With Quote Quick reply to this message  
Join Date: Jul 2008
Posts: 14
Reputation: chellethecat is an unknown quantity at this point 
Solved Threads: 0
chellethecat chellethecat is offline Offline
Newbie Poster

Re: Script works in IE, but not in Firefox

 
0
  #10
Jul 24th, 2008
Thirusha, I replaced the code as you advised but like before no change in performance is seen. It doesn't give an error, but then again it never did in the first place. The scrolling just doesn't work... this is unchanged.

It should be noted that the change Troy suggested was only done to one HTML page and impacted that page only. Your change has now broken the scrolling effect in IE as well as it not working in Firefox still. I've left it in place on the site so you can see it as well.

To look at just pages without the frames...
http://is.rt-games.com/message.html <-- This is the page that has Troy's change on it.

http://is.rt-games.com/main.html <-- This is a page that has had no changes made to it and is only effected by changes to the .js files.
Last edited by chellethecat; Jul 24th, 2008 at 5:15 pm. Reason: Clarification
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the JavaScript / DHTML / AJAX Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC