It only says not to use "javascript:", it doesn't say not to use "javascript:something". Then again though, "javascript:void(0)" is effectively the same as "javascript:"...
This seems to work when left-clicking, but if you right click, the installer will appear anyway and after that, a context-menu will appear.
Are there any onleftclick="" events or something similar?
you have two returns in there, that's why it's doing it twice. It's doing it once with the javascript, then the install completes successfully so it returns 1 and executes the href. you want this code:
This seems to work when left-clicking, but if you right click, the installer will appear anyway and after that, a context-menu will appear.
Are there any onleftclick="" events or something similar?
you have two returns in there, that's why it's doing it twice. It's doing it once with the javascript, then the install completes successfully so it returns 1 and executes the href. you want this code:
djst wrote:Why make it so hard for me all the time?
I was in a hurry and had posted code 2-3 times already
Unfortunately, your suggested code doesn't work any better. It wants to install the extensions twice.
Didn't I tell you to scroll back
Stefan Dec 1 wrote: BTW, the "return false;" should of cource go into the doXPInstall function at the very end, not remain inline like I first posted.
Stefan Dec 1 wrote:
djst wrote:So what is your suggestion?
<a href="http://googlebar.mozdev.org/googlebar_045RC.xpi" onclick="return doXPIInstall('http://googlebar.mozdev.org/googlebar_045RC.xpi','Googlebar 0.4.5 RC');">Click here </a>
Yes, but with "return false;" added to your doXPInstall function (of you will try to install the addon twice).
Scratchs suggestion with removing the return from the first function is perfectly fine, but if you put the return false; in the XPInstall function itself you don't need to add "return false;" in every single onclick="".
It only says not to use "javascript:", it doesn't say not to use "javascript:something". Then again though, "javascript:void(0)" is effectively the same as "javascript:"...
If you read the entire section I link to you will see that it's about not making links that break when agumenting codelanguages (eg Javascript) is not available. That includes "javascript:something", "vbscript:something" and anything else you can come up with that is not standard HTML.
The reason I posted it was to show that the only time I've found Javascript: mentioned in W3C specs/guides is in an example of how NOT to do.
djst wrote:And since the right-click issue is in fact a bug in Mozilla/Gecko, that's not my problem.
I havn't tested this but I just came to think about a possible fix for that problem.
Use "ondblclick" instead of "onclick"
That way a single rightclick shouldn't trigger the script.
That would require the user to double-click to install, wouldn't it? Doesn't sound like an intuitive solution to me. I guess the bug will be fixed soon, and until then, you'll not be able to right-click and save extensions. However, the themes are having a File link too, so they can be saved anyway. I might remove that link once the bug is fixed though.
mozillaZine is an independent Mozilla community and advocacy site. We're not affiliated or endorsed by the Mozilla Corporation but we love them just the same.