Forum Moderators: open

Message Too Old, No Replies

Error expected ;

         

VincentGr

2:46 pm on Oct 5, 2005 (gmt 0)

10+ Year Member



Hello,

I'm not very used with javascript, but with a basic script I made a dropdownmenu. The browser gives a message of some errors in the site (with the menu), but I can't find the problem.
The site works good (beside of the server problems).

Errors are like this (all the same, except the line):

Line: 118
Char: 33
Error: Expected: ';'

A piece of the code (complete code visibly by viewing page source):

<a href="forum/index.php" onClick="return clickreturnvalue(); open url('forum/index.php');" onMouseover="dropdownmenu(this, event, 'main_menu_forum');">
<img name="button_forum" src="templimages/menu/button_forum_off.gif" width="64" height="28" border="0"></a>
<div id="main_menu_forum" class="main_menu" style="width: 115px; border-top: 0px;">
<a class="sub_menu" href="forum/index.php">Forum</a>
<a class="sub_menu" href="forum/profile.php?mode=editprofile">Profiel</a>
<a class="sub_menu" href="forum/profile.php?mode=register">Registreren</a>
</div>

It seems to have some difficulties with the first line. I see no place where an extra ';' is needed en removing them doesn't fix the error.

[edited by: jatar_k at 3:07 pm (utc) on Oct. 5, 2005]
[edit reason] no urls thanks [/edit]

httpwebwitch

5:14 pm on Oct 5, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'd look closer at that "open url()" command

VincentGr

7:54 am on Oct 6, 2005 (gmt 0)

10+ Year Member



And how can I make it correct (I don't know much of JS)?
If I leave the 'open url..' it doenst follow the link. But I guess there's something wrong with the syntax (because there are 2 actions on 'onClick')?

kaled

10:10 am on Oct 6, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Presumably, there is a function elsewhere called openurl(). Therefore, removing the space should fix it. However, this is only a guess.

Kaled.

VincentGr

10:16 am on Oct 6, 2005 (gmt 0)

10+ Year Member



I'll try it out tonight whem I'm at home (I'm now at work). :)

VincentGr

9:06 am on Oct 10, 2005 (gmt 0)

10+ Year Member



I tried, but removing the space results in no link action. The errors dissappeared, but the links didn't work anymore.
I even still don't understand why the href"..."-action is ignored.

johnl

11:51 am on Oct 10, 2005 (gmt 0)

10+ Year Member



hi,

depending on browser and/or html-doctype your problem might have something to do with the fact that html wants "onmouseover", "onclick" etc. instead of mixed lower- uppercase.

good luck!

Rambo Tribble

2:06 pm on Oct 10, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



If the idea of the "open url()" command is to open a new window, perhaps something like this would more appropriate:


<a href="some_page.htm" onclick="window.open(this.href,'','height=200,width=400');return false;">open win</a>

Otherwise, just removing the "open url()" part should allow the links to function, assuming "clickreturnvalue()" is a valid function and doesn't return "false". Removing the entire onclick attribute would allow the links to function, but may break something else.

VincentGr

2:21 pm on Oct 10, 2005 (gmt 0)

10+ Year Member



The idea is to open the link in the same window.
Normally it works with just <a href="link...">, but now with the JS onClick in it, the link doesn't work, which I fixed with open url(link).

RonPK

3:02 pm on Oct 10, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The error, as said, is in the 'open url()'. Whitespaces are not allowed in function names. Is there a function openurl() or open_url() or openUrl() or whatever defined somewhere in your script? And what is clickreturnvalue() supposed to do? (some sort of fix for IE/Mac, I suppose).

VincentGr

3:20 pm on Oct 10, 2005 (gmt 0)

10+ Year Member



returnvalue will probably return a value to open the dropdownmenu. There are for about 5 dropdown menu's in the navigationbar (so 5 times the function open url(); )
I'll post the complete source in a couple of hours when I'm back at home..

Sathallrin

4:51 pm on Oct 10, 2005 (gmt 0)

10+ Year Member



To open the link in the same window, you can use this:

window.location=this.href;

instead of openUrl(this.href) (since openUrl is not a function unless you define it.
So your result will be this:

<a href="forum/index.php" onClick="return clickreturnvalue(); window.location=this.href;" onMouseover="dropdownmenu(this, event, 'main_menu_forum');">

kaled

10:15 pm on Oct 10, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I believe the openurl(); instruction will be ignored due to its following a return value; statement.

Kaled.

RonPK

10:34 pm on Oct 10, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Nice catch, Kaled ;)

If clickreturnvalue returns true, the link defined in href will be followed. If it returns false, the link will not be followed.

Rambo Tribble

1:24 am on Oct 11, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Yes, the return statement will terminate the script so the "return clickreturnvalue();" should follow the invocation of "openurl();", assuming openurl is a valid function.

VincentGr

10:07 am on Oct 11, 2005 (gmt 0)

10+ Year Member



I placed the openurl() (without space) in front of returnvalue() and it seems to work.
On click, you see the icon of an error, which dissapears directly, so that's no problem. :)
Thanx all.