Author Topic: javascript menu in header.html does error message  (Read 8672 times)

0 Members and 1 Guest are viewing this topic.

Offline lutz

  • Addicted member
  • ******
  • Posts: 1.675
    • View Profile
javascript menu in header.html does error message
« on: June 10, 2003, 04:47:38 PM »
hi all,
i inserted a well running javascript menu in the header.html. but here it does an error message. the links are working, but the mouseover and some other effects are gone.
example:
(the link is removed now, because the problem is solved...)
on any other html-site it works perfectly, but unfortunately not here...
???
Grüße, Lutz
kurze antworten sind nicht unhöflich gemeint, sondern effizient
short answers are not meant rude, but just efficient

Offline lutz

  • Addicted member
  • ******
  • Posts: 1.675
    • View Profile
javascript menu in header.html does error message
« Reply #1 on: June 11, 2003, 12:57:34 PM »
ok,
to be more specific:

if i call the header.html directly it works.
if i call the index.php it won´t work in the same way, so it must have to do with some things in the 4images code...

i´m not able to find and correct these problem, because i don´t have any knowledge about php  :(

it´s really a main problem for the whole gallery-site.

is someone here who knows this problem (maybe jan himself  :wink: )?

btw.: am i the only one who has ever tried the implementation of a superior (javascript)menu? or is there a big bug in my procedure?

many thanx in advance!
Grüße, Lutz
kurze antworten sind nicht unhöflich gemeint, sondern effizient
short answers are not meant rude, but just efficient

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
javascript menu in header.html does error message
« Reply #2 on: June 11, 2003, 01:15:27 PM »
try to comment 4images javascript from header.html template.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)

Offline lutz

  • Addicted member
  • ******
  • Posts: 1.675
    • View Profile
javascript menu in header.html does error message
« Reply #3 on: June 11, 2003, 01:27:29 PM »
hallo v@no,
where did you find 4images javascript in the source code of my header.html?
Grüße, Lutz
kurze antworten sind nicht unhöflich gemeint, sondern effizient
short answers are not meant rude, but just efficient

Offline Chris

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 4.487
  • Did u ever stop to think and then forget to start?
    • View Profile
javascript menu in header.html does error message
« Reply #4 on: June 11, 2003, 03:14:56 PM »
Here's a suggestion.  Start up Internet Explorer.  Go to the tools menu and choose "Internet Options...".  Click the "Advanced" tab.  Uncheck "Disable script debugging".  Check "Display a notification about every script error".  Load your main page.

You will find the line numbers, character numbers and a message stating what the problem is displayed in a dialog box each time your javascript is run and hits a problem.  This will help you isolate what is going on.

I tried it and started to find these:
Code: [Select]
Line: 16
Char: 9
Error: Syntax error


Code: [Select]
Line: 26
Char: 9
Error: Syntax error


Code: [Select]
Line: 123
Char: 1
Error: 'version' is undefined


Using this info, right away I can see a problem here:
Code: [Select]
       function blurLink(theObject)        {
                if (msie4)        
        }

You've got an if-statment that is incomplete since it's missing the "then" portion.  If msie4, then what?

Finally, here's a good reference for you:
http://www.devguru.com/Technologies/ecmascript/quickref/javascript_intro.html

Offline lutz

  • Addicted member
  • ******
  • Posts: 1.675
    • View Profile
javascript menu in header.html does error message
« Reply #5 on: June 11, 2003, 03:58:44 PM »
first, thanx for this detailed examination!
although i´m not able to write javascript (the menu is just copied from the output of my cms http://www.typo3.org) it´s very interesting to see the following:
if you call the header.html directly (with the link above) the source code displays:
Quote
       function blurLink(theObject)        {
                if (msie4)        {theObject.blur();}
        }

if you call the index.php it shows
Quote
       function blurLink(theObject)        {
                if (msie4)
        }

???
Grüße, Lutz
kurze antworten sind nicht unhöflich gemeint, sondern effizient
short answers are not meant rude, but just efficient

Offline Chris

  • 4images Moderator
  • 4images Guru
  • *****
  • Posts: 4.487
  • Did u ever stop to think and then forget to start?
    • View Profile
javascript menu in header.html does error message
« Reply #6 on: June 11, 2003, 05:11:22 PM »
I have the answer now.  You need to edit your javascript.  Code such as this:
Code: [Select]
{theObject.blur();}will be treated as a template tag by 4images!  Thus since there is no tag named "theObject.blur();", it is removed by 4images.  To fix this, change the javascript code to this:
Code: [Select]
{
theObject.blur();
}
or move the entire script to a separate MyMenu.js and include it in header.html like this:
Code: [Select]
<script type="text/javascript" src="/scripts/MyMenu.js" language="JavaScript"></script>assuming you put the MyMenu.js file in a top-level directory named "scripts".  This way 4images won't parse your javascripts looking for 4images template tags.

Offline lutz

  • Addicted member
  • ******
  • Posts: 1.675
    • View Profile
javascript menu in header.html does error message
« Reply #7 on: June 11, 2003, 06:49:01 PM »
hey, that was the trick!!

there were some other lines to change the syntax too and now it works!

my annotation is:
1) you have found the problem
2) it depends really on the 4images script(!)
3) you have found... :wink:

regarding point 2):
this problem with the syntax should be a general advice to other people who will have the same problem in the future, shouldn´t it?

many thanx!
Grüße, Lutz
kurze antworten sind nicht unhöflich gemeint, sondern effizient
short answers are not meant rude, but just efficient

Offline V@no

  • If you don't tell me what to do, I won't tell you where you should go :)
  • Global Moderator
  • 4images Guru
  • *****
  • Posts: 17.849
  • mmm PHP...
    • View Profile
    • 4images MODs Demo
javascript menu in header.html does error message
« Reply #8 on: June 11, 2003, 08:46:06 PM »
Quote from: lutz
regarding point 2):
this problem with the syntax should be a general advice to other people who will have the same problem in the future, shouldn´t it?

First of all, with a huge javascript as yours, I'd more all the code in .js file in the first place. This way u'd save some bandwith, because most of visitors wont need download this .js file each time they open page on your site (just first time download, then most browsers would use it from cache).
Second, I havent seen before javascripts that would use something like
Quote
if (msie4) {theObject.blur();}
I think this is just a waste.
Your first three "must do" before you ask a question:
Please do not PM me asking for help unless you've been specifically asked to do so. Such PMs will be deleted without answer. (forum rule #6)
Extension for Firefox/Thunderbird: Master Password+    Back/Forward History Tweaks (restartless)    Cookies Manager+    Fit Images (restartless for Thunderbird)