Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Special Interests > Visual Media > Web Design and Development

Reply
 
Thread Tools Search this Thread Display Modes
Old Jun 2, 2013, 06:14 PM   #1
BG29
macrumors newbie
 
Join Date: Jun 2013
I have a javascript working great on Mozilla but not on Safari or Chrome

Do you have any suggestion?

I modified some codes from http://www.w3schools.com/xml/ and get something fine to parse XML database.
Well ... at least it is fine with Mozilla on a PC... but it does not work either with Safari or Chrome on a Mac (or PC) ... any suggestion is most welcome!
the page is on:
http://paleopolis.rediris.es/cg/test/browse.html
and the related files are on:
http://paleopolis.rediris.es/cg/test/browse.js
http://paleopolis.rediris.es/cg/test/display.js
http://paleopolis.rediris.es/cg/test/FCnP.xml

Thanks in advance!
BG29 is offline   0 Reply With Quote
Old Jun 3, 2013, 01:11 PM   #2
SrWebDeveloper
macrumors 68000
 
SrWebDeveloper's Avatar
 
Join Date: Dec 2007
Location: Alexandria, VA, USA
 
So I typed in "7" and pressed Enter and saw some author/year/title info from your XML DB display above the buttons, but not on Chrome. Console inspection on Chrome reveals:

Quote:
Uncaught TypeError: Cannot call method 'getElementsByTagName' of null browse.js:18
Uncaught ReferenceError: x is not defined display.js:12
Uncaught ReferenceError: x is not defined browse.js:23
Uncaught ReferenceError: x is not defined browse.js:23
These issues do not appear to be browser specific, simply that some browsers parse JS very strictly which means you need to adjust your code (in a few places) so variables and objects are properly defined or referenced to work in a strict environment for cross browser compatibility. See listing of errors above to help you know where to look and what to fix.

Example: in display.js line 12 the "x" you have:

Code:
for (var i=1;i<x.length;i++)
But "x" is not defined locally (in display.js) or globally, apparently, so some browser might return 0 for x.length while others properly complain about it. Follow best practices and always define var's properly and less headaches and better cross platform compatibility, plus code is easier to follow when debugging. I didn't spend much time debugging, so this is informal advice.

Use Crome and its built in inspection tools and use the console tab for checking JS errors. Add on the Web Developer extension and you can even local edit! FYI.

Cheers.
__________________
Jim Goldbloom
Sr. Web Developer, owner GoldTechPro, LLC
http://www.GoldTechPro.com

Last edited by SrWebDeveloper; Jun 3, 2013 at 01:26 PM. Reason: Typo
SrWebDeveloper is offline   0 Reply With Quote
Old Jun 3, 2013, 06:00 PM   #3
BG29
Thread Starter
macrumors newbie
 
Join Date: Jun 2013
"I am not an IT person"

THANKS ...
I get your points (there are errors in my code, I should use this Chrome facility, ...).
I should try to learn more on javascript and possibly to better understand what I "wrote" (="copied and pasted") ...
but I am not an IT person (I am a paleontologist ...).

Therefore --in the mean time-- any support is most welcome.

Thanks again (and in advance)
BG29 is offline   0 Reply With Quote
Old Jun 4, 2013, 10:02 PM   #4
960design
macrumors 6502a
 
Join Date: Apr 2012
Location: Destin, FL
Haha! Maybe I just caught this with the correct amount of port in me, but this cracked me up ( in a fantastic way ).

I love this part:
Quote:
but I am not an IT person (I am a paleontologist ...).
I'm making a T-Shirt and probably a coffee mug out of that!

Here's what my befuddled (thank you spell checker) mind thinks:
When my dog digs up a huge dino bone, I'm going to head over to your forum and ask questions and when given reasonable answers respond with: Yeah, yeah, i get it, I shouldn't be using a chainsaw to chop this thing up into more mangeable pieces, but I'm an IT guy not a palentologist ( think I'd get on a T-Shirt? ).

Okay... to actually help you we would need to see the source code and find out why you didn't assign a default value to x. And show you where and how to do that.

Could you post your source? I'll be sure to post pictures of the dino bone my dog digs up.

PS Please forgive me, upon rereading that it was meant to be funny but seemed mean, I promise I mean no snide or ill in your direction. I just truly thought your response was funny.
__________________
TI-99/4A, tape cassette, 12" B&W Zenith
960design is offline   0 Reply With Quote
Old Jun 5, 2013, 01:55 AM   #5
BG29
Thread Starter
macrumors newbie
 
Join Date: Jun 2013
http://paleopolis.rediris.es/cg/test/browse_test.html

Hi,
you will find the code on the URL links of my first message (with .js files set apart) ... the "new" URL of the title gets the JS in the HTML code!

It is not a problem making humour with "my quote".

Apologies for my poor English too ...

If you are clever (I assume you are) and a little curious
you possibly removed the final "display.js" to get access to the folder at
http://paleopolis.rediris.es/cg/test/
(if you are even more curious you would have removed "test/" and found that I am editing an Open Access scientific journal)

You will find that I am using a set of script called Tipue, which is very effective to search in a flat JS database.

And you will also find the browse related items ... the ones that do not work!
I copied most of the pieces of code from SEVERAL scripts available at
http://www.w3schools.com/xml/xml_parser.asp
or
http://www.w3schools.com/xml/tryit.a...ame=tryxml_app
and tried to assemble them in the "good" way
...
it worked with Firefox, not with Safari or Chrome

I first thought it was a Mac issue (because I do not have Chrome and Safari on my PC) as I checked whether it was working on an Ipad and then on my Mac (I do not have Firefox on my Mac, nor Chrome)

So may be I am not in the good forum to help solve this problem.

Let us go back to what I ideally wished:
1) getting a search engine to browse a database (I get this with Tipue but I had to rewrite my original XML database and convert it into a flat JS database)
2) getting a tool to screen each entry of my XML data, with in addition the possibility to go to a discrete entry, to go to entries 1, 5 and 20 steps below or above
this is this part which I did not manage to build correctly ...

what I am doing is like cooking with a cookbook in Spanish (that I understand at 80%) and eventually without having the good ingredients ...

If this issue can be fixed it might be a very practical tool for small database (the one we use here get some 7600 entries)



Thanks for your appreciated help



I should mention that I checked the "JS console" on Chrome as suggested by SrWebDeveloper but AGAIN the red quotes looked like Chinese too me
BG29 is offline   0 Reply With Quote
Old Jun 5, 2013, 07:32 AM   #6
960design
macrumors 6502a
 
Join Date: Apr 2012
Location: Destin, FL
Quote:
Originally Posted by BG29 View Post
Apologies for my poor English too ...
What? Your english is better than english writers that make millions by writing english text books, so don't worry about that at all.

I did not browse your code, most of us have limited time, and cannot dive too deeply in another's code, that's why I asked you to copy paste the relative parts. For example, right now I have about three minutes until my compile is done and then back to work. I really don't have the time to download and search your hard work, as I'm in the process of fixing mine ( actually someone else's code, but that's a different story ).
__________________
TI-99/4A, tape cassette, 12" B&W Zenith
960design is offline   0 Reply With Quote
Old Jun 5, 2013, 09:28 AM   #7
SrWebDeveloper
macrumors 68000
 
SrWebDeveloper's Avatar
 
Join Date: Dec 2007
Location: Alexandria, VA, USA
 
I laughed out loud, too, when I saw "but I am not an IT person (I am a paleontologist ...)" and here's my $1.99 for a T-shirt.

I'm in agreement with 960design, BG29. Most of us cannot take the time to resolve all the code fixes which in this case are not merely syntax errors but changes involving missing pieces since you copy/pasted and merged code from different sources. In this unique kind of situation we do what I did in my first reply, offer suggestions and point out what failed and notably how to more quickly debug those issues using the common tools we in IT use all the time.

You might find someone here willing to dive into your mixed/merged code and create a better script from it that 1) resolves the browser compatibility issues and 2) performs the task as you described in your last reply. Or, as you said:

Quote:
I should try to learn more on javascript and possibly to better understand what I "wrote" (="copied and pasted")
.... or hire a professional.
__________________
Jim Goldbloom
Sr. Web Developer, owner GoldTechPro, LLC
http://www.GoldTechPro.com
SrWebDeveloper is offline   0 Reply With Quote
Old Jun 16, 2013, 11:07 AM   #8
BG29
Thread Starter
macrumors newbie
 
Join Date: Jun 2013
Fixed!

well actually I had to set the code to generated a discrete id for each div
I replaced
Code:
  document.write("<div id='showCD' onclick='displayCDInfo(" + i + ")'></div>");
with
Code:
document.write("<div id='showCD(" + i + ")' onclick='displayCDInfo(" + i + ")'></div>");
it works with Chrome too



anyway if you have a better ("smarter") way to get the same results I would welcome it (and acknowledge it in the forthcoming publication).

Cheers,
&
Ciao,
Bruno
BG29 is offline   0 Reply With Quote

Reply
MacRumors Forums > Special Interests > Visual Media > Web Design and Development

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
Canīt access Spotify.com (both safari and mozilla) eemittoo MacBook Pro 0 Apr 28, 2014 07:01 PM
Safari in iOS 7: great ideas but not great execution. iphnhelp iOS 7 43 Jul 15, 2013 01:46 PM
Chrome preredering not working in Chrome 26 kristoffer4 Mac Applications and Mac App Store 0 Apr 1, 2013 12:41 PM
How Safari Pretended to Be Mozilla Before It Was Released MacRumors Mac Blog Discussion 87 Jan 8, 2013 03:45 PM
built in camera not working in safari but does in Chrome? josh bear Mac Applications and Mac App Store 0 Dec 16, 2012 12:06 PM

Forum Jump

All times are GMT -5. The time now is 04:22 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC