vvega said:
I have to say I am totally ignorant in javascript...:|
Which means you don't really know what you are doing. Unfortunately
nobody else knows what you are doing unless you show them the code you
are using. Describing it is almost totally worthless as there are
usually at least half a dozen ways of doing anything with javascript,
and at least 50 ways of failing to do anything.
What you are left with is guesswork, informed or otherwise. You describe
what you are doing as activated onclick, but onclick events do not cause
unexpected side effects. On the other hand the well known cause of
unexpected side effects (and most commonly made apparent by animated
GIFs stopping animating) is the execution of javascript pseudo-protocol
HREFs in links. This implies that your link formulation is along the
lines of:-
I added "return false;" at the end of the script but it
doesnt make the effect I am looking for.
Ivo's suggestion of adding 'return false:' is a solution as returning
false will cancel the navigation and prevents the execution of the
javascript pseudo-protocol HREF, and so prevent the side effects of its
execution. It is however important to put the 'return false;' in the
right place, and "at the end of the script" is not enough information to
be able to tell whether you tried it in the right place. The result
should have resembled:-
<a href="javascript:void 0;" onclick="doSomethong();return false;">
- else the return false may be the last line in the function called, but
that required the onclick code to pass that returned value on by
returning the return value of the function call. I.E.:-
<a href="javascript:void 0;" onclick="return doSomethong();">
Neither of these changes will be effective if the function called in the
onclick handler generates a runtime error while it is executed, and we
cannot estimate the likelihood of that happening without seeing the code
being used.
Additionally, once the onclick handler is cancelling the navigation the
contents of the HREF become irrelevant in an environment where
javascript is enabled, and a javascript pseudo-protocol HREF is
inevitably worthless in an environment where javascript is not
available. As the HREF is irrelevant when javascript is available it
becomes free for use providing fall-back for javascript disabled
browsers. Which can be done by providing an HREF that is the URL of a
real resource (probably the URL of whichever resource you were planning
on opening in this new window). See:-
Do you have any other suggestion?
1. Never ever use a javascript pseudo-protocol HREF.
2. Give up entirely on trying to open new windows with javascript, it is
more trouble than it is worth.
Richard.