Ask a Question related to Dreamweaver AppDev, Design and Development.
-
bthouin #1
the ominous onClick problem
Hi,
I have added 3 simple pictures (for 3 languages to be supported) to a
page made with DW MX 2004, and added an onClick action to each of them
(to set the corresponding language).
When the page loads, obviously, all 3 onClick actions are performed
without me clicking at all on these pictures. I have already had that
earlier with other controls like buttons, and never got to the bottom of it.
So my question is: why do controls with a USER action fire up at page
load time, BEFORE any user action is possible ??? This, to me, defies
any logic. But more to the point, how do I prevent this from happening,
so that my onClick actions are really only executed when the user is
physically clicking on that control ?
Thanks for help.
regards
bernard
bthouin Guest
-
How do you set up the OnClick with ASP 2.0 ?
In my 1.1 project, I was creating dynamically a LinkButton, and stored it into a Table.Row.Cell.Controls(). I was adding an MyOnClick handler to... -
Image: MouseOver - MouseOut - OnClick problem
Imagine this: I have a gif-image with text, coloured green. When MouseOver occurs the gif will swap to another gif with red colourded text. On... -
[PHP] OnClick problem (fwd)
phpinfo() "Andu" <toma@cloud9.net> wrote in message news:37710000.1057867993@localhost... with <djoseph@duhq.us> pieces... -
[PHP] OnClick problem
Hi, Are you using the variable $_SERVER for your link target? -Dan Joseph -
OnClick problem
Here's something I cant explain: I have a page with a form on it (checkboxes) and a hyperlink which is supposed to send the form to the server... -
Paul Whitham TMM #2
Re: the ominous onClick problem
I have never had a button fire on page load so can you post me your page
code and I will see if I can identify the problem.
--
Regards
Paul Whitham
Macromedia Certified Professional for Dreamweaver MX2004
Valleybiz Internet Design
[url]www.valleybiz.net[/url]
Team Macromedia Volunteer for Ultradev/Dreamweaver MX
[url]www.macromedia.com/support/forums/team_macromedia[/url]
"bthouin" <bernard_thouin@bluewin.ch> wrote in message
news:d0877k$jij$1@forums.macromedia.com...it.> Hi,
>
> I have added 3 simple pictures (for 3 languages to be supported) to a
> page made with DW MX 2004, and added an onClick action to each of them
> (to set the corresponding language).
>
> When the page loads, obviously, all 3 onClick actions are performed
> without me clicking at all on these pictures. I have already had that
> earlier with other controls like buttons, and never got to the bottom of>
> So my question is: why do controls with a USER action fire up at page
> load time, BEFORE any user action is possible ??? This, to me, defies
> any logic. But more to the point, how do I prevent this from happening,
> so that my onClick actions are really only executed when the user is
> physically clicking on that control ?
>
> Thanks for help.
>
> regards
> bernard
Paul Whitham TMM Guest
-
bthouin #3
Re: the ominous onClick problem
Paul Whitham TMM wrote:
I think I know what the problem is: I have coded the onClick like this:> I have never had a button fire on page load so can you post me your page
> code and I will see if I can identify the problem.
>
<td width="15%"><span class="style16b"><img src="images/lng_fr.gif"
width="58" height="30" onClick="<% var Lang = "FRCH" %>"></span></td>
This is a SERVER-side script ! So it will be run regardless when the
page is parsed by the server. It should be a client-side script. What's
the exact syntax ? Can I just add a runat="client" ? Or do I need a
<script></script> tag pair ? Or a <Javascript: syntax ?
Bernard
bthouin Guest
-
Paul Whitham TMM #4
Re: the ominous onClick problem
I think that the issue is that onClick is not really suitable for assigning
to a image. Have you tried associating it with an a gref tag like this
<td width="15%"><span class="style16b"><a href="#" onClick="<% var Lang =
"FRCH" %>"><img src="images/lng_fr.gif"
width="58" height="30" border="0" ></a></span></td>
--
Regards
Paul Whitham
Macromedia Certified Professional for Dreamweaver MX2004
Valleybiz Internet Design
[url]www.valleybiz.net[/url]
Team Macromedia Volunteer for Ultradev/Dreamweaver MX
[url]www.macromedia.com/support/forums/team_macromedia[/url]
"bthouin" <bernard_thouin@bluewin.ch> wrote in message
news:d08agn$nsg$1@forums.macromedia.com...> Paul Whitham TMM wrote:>> > I have never had a button fire on page load so can you post me your page
> > code and I will see if I can identify the problem.
> >
> I think I know what the problem is: I have coded the onClick like this:
> <td width="15%"><span class="style16b"><img src="images/lng_fr.gif"
> width="58" height="30" onClick="<% var Lang = "FRCH" %>"></span></td>
>
> This is a SERVER-side script ! So it will be run regardless when the
> page is parsed by the server. It should be a client-side script. What's
> the exact syntax ? Can I just add a runat="client" ? Or do I need a
> <script></script> tag pair ? Or a <Javascript: syntax ?
>
> Bernard
Paul Whitham TMM Guest
-
bthouin #5
Re: the ominous onClick problem
Paul Whitham TMM wrote:
Well, I found a syntax (after 1000 and one trials, I nearly lost> I think that the issue is that onClick is not really suitable for assigning
> to a image. Have you tried associating it with an a gref tag like this
>
> <td width="15%"><span class="style16b"><a href="#" onClick="<% var Lang =
> "FRCH" %>"><img src="images/lng_fr.gif"
> width="58" height="30" border="0" ></a></span></td>
>
>
patience completely!) which works perfectly (at least in IE):
<td width="15%"><span class="style16b"><img src="images/lng_de.gif"
width="58" height="30" onClick="SetLang('DECH')"></span></td>
This calls a new SetLang client-side function, where I just do the 'Lang
= "FRCH"' bit.
But in principle, you are right. DW tells me that the onClick on an
image is not supported by Netscape...
Now my next problem is: now that the language code is set, I should
re-load (refresh) the page for the texts to be loaded in the new
language. That should be dead easy, but... I don't know how to do that
from the client side (can't use Response.Redirect(same page), can I !) !
I tried history.go(-1) (in my SetLang function, and also in the
onClick), but nothing happens. Any suggestions ?
Thanks for your time
bernard
bthouin Guest
-
CMBergin #6
Re: the ominous onClick problem
Put a form on the bottom of the page:
<form name="LangSwitch" method="get" action="thisPage.asp">
<input name="Lang" type="hidden" value="">
</form>
Your SetLang function should now be as follows:
function SetLang(Language)
{
document.LangSwitch.Lang.value = Language;
document.LangSwitch.submit()
}
You can now retrieve the new language when the page reloads with
Request.QueryString("Lang")
By using a GET form, you can also come to this page with a predefined
language just by using the querystring:
Response.Redirect("ThisPage.asp?Lang=DECH")
"bthouin" <bernard_thouin@bluewin.ch> wrote in message
news:d08eq5$t5u$1@forums.macromedia.com...assigning> Paul Whitham TMM wrote:> > I think that the issue is that onClick is not really suitable for=> > to a image. Have you tried associating it with an a gref tag like this
> >
> > <td width="15%"><span class="style16b"><a href="#" onClick="<% var Lang> Well, I found a syntax (after 1000 and one trials, I nearly lost> > "FRCH" %>"><img src="images/lng_fr.gif"
> > width="58" height="30" border="0" ></a></span></td>
> >
> >
> patience completely!) which works perfectly (at least in IE):
> <td width="15%"><span class="style16b"><img src="images/lng_de.gif"
> width="58" height="30" onClick="SetLang('DECH')"></span></td>
> This calls a new SetLang client-side function, where I just do the 'Lang
> = "FRCH"' bit.
> But in principle, you are right. DW tells me that the onClick on an
> image is not supported by Netscape...
>
> Now my next problem is: now that the language code is set, I should
> re-load (refresh) the page for the texts to be loaded in the new
> language. That should be dead easy, but... I don't know how to do that
> from the client side (can't use Response.Redirect(same page), can I !) !
> I tried history.go(-1) (in my SetLang function, and also in the
> onClick), but nothing happens. Any suggestions ?
>
> Thanks for your time
> bernard
CMBergin Guest
-
Michael Fesser #7
Re: the ominous onClick problem
.oO(bthouin)
Why you should not use a flag as a symbol of language>I have added 3 simple pictures (for 3 languages to be supported)
[url]http://www.cs.tut.fi/~jkorpela/flags.html[/url]
Why do you need an onClick at all? What about users without Javascript?>When the page loads, obviously, all 3 onClick actions are performed
>without me clicking at all on these pictures. I have already had that
>earlier with other controls like buttons, and never got to the bottom of it.
What's wrong with plain links to different versions of the site?
Micha
Michael Fesser Guest
-
bthouin #8
Re: the ominous onClick problem
CMBergin wrote:
Hi,> Put a form on the bottom of the page:
> <form name="LangSwitch" method="get" action="thisPage.asp">
> <input name="Lang" type="hidden" value="">
> </form>
>
> Your SetLang function should now be as follows:
> function SetLang(Language)
> {
> document.LangSwitch.Lang.value = Language;
> document.LangSwitch.submit()
> }
>
> You can now retrieve the new language when the page reloads with
> Request.QueryString("Lang")
> By using a GET form, you can also come to this page with a predefined
> language just by using the querystring:
> Response.Redirect("ThisPage.asp?Lang=DECH")
>
> "bthouin" <bernard_thouin@bluewin.ch> wrote in message
> news:d08eq5$t5u$1@forums.macromedia.com...
>>>>Paul Whitham TMM wrote:
>>>>>I think that the issue is that onClick is not really suitable for
> assigning
>>>>>to a image. Have you tried associating it with an a gref tag like this
>>>
>>><td width="15%"><span class="style16b"><a href="#" onClick="<% var Lang
> =
>>>>Well, I found a syntax (after 1000 and one trials, I nearly lost>>>"FRCH" %>"><img src="images/lng_fr.gif"
>>>width="58" height="30" border="0" ></a></span></td>
>>>
>>>
>>patience completely!) which works perfectly (at least in IE):
>><td width="15%"><span class="style16b"><img src="images/lng_de.gif"
>>width="58" height="30" onClick="SetLang('DECH')"></span></td>
>>This calls a new SetLang client-side function, where I just do the 'Lang
>>= "FRCH"' bit.
>>But in principle, you are right. DW tells me that the onClick on an
>>image is not supported by Netscape...
>>
>>Now my next problem is: now that the language code is set, I should
>>re-load (refresh) the page for the texts to be loaded in the new
>>language. That should be dead easy, but... I don't know how to do that
>>from the client side (can't use Response.Redirect(same page), can I !) !
>>I tried history.go(-1) (in my SetLang function, and also in the
>>onClick), but nothing happens. Any suggestions ?
>>
>>Thanks for your time
>>bernard
>
>
Thanks a LOT for your post. THIS put me exactly and finally on the right
track, and now the stuff works smoothly. I had to fight about the
"undefined" value of the URL parameter on the first page load, though,
and after that also about the initially undefined value of a session
variable which I decided to set (couldn't find out how to define an 'if
var = undefined' at first, especially as session variables and URL
parameters do not have the same typeof()...), but all is fine now.
I had already a separate form for the language "flags", so adding the
hidden input was easy and setting and reading it worked very well (to my
surprise, because that's an other subject where I had big problems
lately). The thing I didn't know at all, though, was the
'document.form.submit' bit ! That's exactly what I was missing.
Regards
Bernard
bthouin Guest
-
bthouin #9
Re: the ominous onClick problem
Michael Fesser wrote:
Micha,> .oO(bthouin)
>
>>>>I have added 3 simple pictures (for 3 languages to be supported)
>
> Why you should not use a flag as a symbol of language
> [url]http://www.cs.tut.fi/~jkorpela/flags.html[/url]
>
>>>>When the page loads, obviously, all 3 onClick actions are performed
>>without me clicking at all on these pictures. I have already had that
>>earlier with other controls like buttons, and never got to the bottom of it.
>
> Why do you need an onClick at all? What about users without Javascript?
> What's wrong with plain links to different versions of the site?
>
> Micha
My "simple pictures" are actually flags...
What ?? Schock horror ! You don't think I'm EVER going to have 4 pages>>What's wrong with plain links to different versions of the site?<<
with exactly the same sh.., each just in one of the 4 languages I should
support for a start ?! What about maintenance ? Fixing the same bug 4
times ? Jesus... I have ONE page only, all texts are read from the
database in the proper language. Anything else is just bad design, in my
view.
Now I start to understand why I read posts by people saying that they
have "a 600 pages site". Well, if it actually consists of 30 pages, but
in 20 languages, and they follow your technique, no wonder they get 600
at the end. How can you ever maintain such monsters ?
OK, I don't have the problem of left-to-right and right-to-left reading
(I'm in Switzerland, developing for Swiss users, so I have just 4
Europen languages to support). But, if I had, I'd try to have all the
input / data controls in the middle, and the labels/texts on each side,
and I'd have again only one page for most of the cases.
Cheeers. And forget about your link to the flags page, it is old (2000),
and full of dead links (and hardly contains any flags)
Bernard
bthouin Guest
-
Michael Fesser #10
Re: the ominous onClick problem
.oO(bthouin)
I should have written "different URLs" instead ... my fault.>>>What's wrong with plain links to different versions of the site?
>What ?? Schock horror ! You don't think I'm EVER going to have 4 pages
>with exactly the same sh.., each just in one of the 4 languages I should
>support for a start ?!
Four versions of a page doesn't necessarily mean 4 different files on
the server, it can all be handled by a single script.
That's OK.>What about maintenance ? Fixing the same bug 4
>times ? Jesus... I have ONE page only, all texts are read from the
>database in the proper language.
In mine too, but it's also bad design to rely on Javascript without>Anything else is just bad design, in my
>view.
providing a fallback. And your posted example code didn't look like it
would also work if no JS is available.
In my current testing environment I use URLs like this:>Now I start to understand why I read posts by people saying that they
>have "a 600 pages site". Well, if it actually consists of 30 pages, but
>in 20 languages, and they follow your technique, no wonder they get 600
>at the end. How can you ever maintain such monsters ?
[url]http://www.example.com/deutsch/[/url]
[url]http://www.example.com/english/[/url]
[url]http://www.example.com/espanol/[/url]
This can be rewritten internally on the server (on Apache servers with
mod_rewrite) to something like
[url]http://www.example.com/?lang=de[/url]
[url]http://www.example.com/?lang=en[/url]
[url]http://www.example.com/?lang=es[/url]
so the script is able to get the requested language from the URL
parameter and deliver the content accordingly. From the viewpoint of the
browser there are three different pages, internally it's all the same.
The issue "flag <> language" is still valid.>Cheeers. And forget about your link to the flags page, it is old (2000),
>and full of dead links (and hardly contains any flags)
Micha
Michael Fesser Guest
-
bthouin #11
Re: the ominous onClick problem
Hi Michael,
Thanks for your comments. You have a point with JS. Who in your opinion
would block JS these days ?
The site enhancements I am working on are for 2 different types of
clientele:
- independant insurance brokers and financial advisors. These people are
typically one-man shows, or small companies (up to 10 people?). I don't
think they will care if JS or not, so they should be no trouble anyway
- insurance companies. There of course the IT decides. What's your
experience (I guess you're US.based, right?) about such companies and JS
acceptance ?
I am working in a MS-only environment in this project. Web server is
IIS, the existing site is using VBScript, a bit of MS Access (for user
authentication). I am adding another lot of VBScript and MS SQLServer.
In fact, the only page so far in JS is this one with the language
choice. It now has only ONE really JS-needing function, all the rest
could be converted straight back to VBS, as it's server-side stuff
anyway, and the rest is plain HTML
Actually, I am nearly doing your "www.example.com/?lang=de" trick, only
I don't have the "/"... And, currently, this is at the expense of only
ONE single JS client-side function (with 2 lines of code, as outlined by
CMBergin). If JS is not there, then the language is set to default
(currently Swiss German). As I plan to define a user-linked langauge in
the user table, even the whole language choice might be rather a gimmick
than a feature. But to me, it was important to achieve some client-side
handling. I learnt something, and that was important as well.
I agree totally with you, there is no direct link, but don't you think>>flag=language<<
that the technique of using flags (however objectable it is) is so
popular that you can hardly avoid it ? Or only at the risk of being
labeled "boring", because ther are "no visual incentives" on the page,
and clients are convinced it is what counts...
Regards
Bernard
Michael Fesser wrote:> .oO(bthouin)
>
>>>>>>>What's wrong with plain links to different versions of the site?
>>What ?? Schock horror ! You don't think I'm EVER going to have 4 pages
>>with exactly the same sh.., each just in one of the 4 languages I should
>>support for a start ?!
>
> I should have written "different URLs" instead ... my fault.
>
> Four versions of a page doesn't necessarily mean 4 different files on
> the server, it can all be handled by a single script.
>
>>>>What about maintenance ? Fixing the same bug 4
>>times ? Jesus... I have ONE page only, all texts are read from the
>>database in the proper language.
>
> That's OK.
>
>>>>Anything else is just bad design, in my
>>view.
>
> In mine too, but it's also bad design to rely on Javascript without
> providing a fallback. And your posted example code didn't look like it
> would also work if no JS is available.
>
>>>>Now I start to understand why I read posts by people saying that they
>>have "a 600 pages site". Well, if it actually consists of 30 pages, but
>>in 20 languages, and they follow your technique, no wonder they get 600
>>at the end. How can you ever maintain such monsters ?
>
> In my current testing environment I use URLs like this:
>
> [url]http://www.example.com/deutsch/[/url]
> [url]http://www.example.com/english/[/url]
> [url]http://www.example.com/espanol/[/url]
>
> This can be rewritten internally on the server (on Apache servers with
> mod_rewrite) to something like
>
> [url]http://www.example.com/?lang=de[/url]
> [url]http://www.example.com/?lang=en[/url]
> [url]http://www.example.com/?lang=es[/url]
>
> so the script is able to get the requested language from the URL
> parameter and deliver the content accordingly. From the viewpoint of the
> browser there are three different pages, internally it's all the same.
>
>>>>Cheeers. And forget about your link to the flags page, it is old (2000),
>>and full of dead links (and hardly contains any flags)
>
> The issue "flag <> language" is still valid.
>
> Michabthouin Guest
-
Michael Fesser #12
Re: the ominous onClick problem
.oO(bthouin)
Don't know, but I would think more than enough. There are so many nasty>Thanks for your comments. You have a point with JS. Who in your opinion
>would block JS these days ?
things you can do with JS to annoy the users, it makes perfect sense to
disable it or at least restrict it if the browser allows that.
There are also some user agents that don't support JS at all and there
are firewalls that might filter scripts out completely before the sites
are delivered to a company's intranet.
Personally I always consider JS just a secondary option to add some
convenience features, but everything has to work without JS as well.
Not much in this case.>There of course the IT decides. What's your
>experience
Nope, DE. ;)>(I guess you're US.based, right?)
In the URL above the '/' is optional (but a browser will probably insert>Actually, I am nearly doing your "www.example.com/?lang=de" trick, only
>I don't have the "/"...
it automatically). It's used as a delimiter between the host part and
the path, which is empty in this case.
Yep, it's very popular. But it's wrong, so I try to avoid it.>I agree totally with you, there is no direct link, but don't you think
>that the technique of using flags (however objectable it is) is so
>popular that you can hardly avoid it ?
Micha
Michael Fesser Guest
-
bthouin #13
Re: the ominous onClick problem
>>There are so many nasty things you can do with JS to annoy the users<<
Like what for example ?
OK, if I want to do without JS what I do currently with JS (setting a
document element (a hidden input text field) to the chosen language
value on the client and submitting the document to the server), what are
my alternatives ?
So, so. Da sind wir ja nicht so weit entfernt... South ? Middle ? North ?>>Nope, DE. ;)<<
Gruss
bernard
Michael Fesser wrote:> .oO(bthouin)
>
>>>>Thanks for your comments. You have a point with JS. Who in your opinion
>>would block JS these days ?
>
> Don't know, but I would think more than enough. There are so many nasty
> things you can do with JS to annoy the users, it makes perfect sense to
> disable it or at least restrict it if the browser allows that.
>
> There are also some user agents that don't support JS at all and there
> are firewalls that might filter scripts out completely before the sites
> are delivered to a company's intranet.
>
> Personally I always consider JS just a secondary option to add some
> convenience features, but everything has to work without JS as well.
>
>>>>There of course the IT decides. What's your
>>experience
>
> Not much in this case.
>
>>>>(I guess you're US.based, right?)
>
> Nope, DE. ;)
>
>>>>Actually, I am nearly doing your "www.example.com/?lang=de" trick, only
>>I don't have the "/"...
>
> In the URL above the '/' is optional (but a browser will probably insert
> it automatically). It's used as a delimiter between the host part and
> the path, which is empty in this case.
>
>>>>I agree totally with you, there is no direct link, but don't you think
>>that the technique of using flags (however objectable it is) is so
>>popular that you can hardly avoid it ?
>
> Yep, it's very popular. But it's wrong, so I try to avoid it.
>
> Michabthouin Guest
-
Michael Fesser #14
Re: the ominous onClick problem
.oO(bthouin)
Positioning or resizing the current window, manipulating the status bar,>Like what for example ?> >>There are so many nasty things you can do with JS to annoy the users<<
trying to disable context menus, images flying around the mouse cursor,
form fields resetting after the page loaded, ...
I'm not sure in your case, since I don't know how you handle it on the>OK, if I want to do without JS what I do currently with JS (setting a
>document element (a hidden input text field) to the chosen language
>value on the client and submitting the document to the server), what are
>my alternatives ?
server. As posted earlier I would do it with a URL parameter 'lang' or
something, the script would then deliver the content acccording to that
parameter.
Eher östlich, aber eigentlich doch mittendrin: Berlin.>> >>Nope, DE. ;)<<
>So, so. Da sind wir ja nicht so weit entfernt... South ? Middle ? North ?
Micha
Michael Fesser Guest



Reply With Quote

