I am trying to use the prototype framework to hide a ‘< div >’ based on a particular URL. I don’t have access to server side – so I have no choice but to do this using prototype [restriction of platform using prototype].
Wondering if someone could tell me how to do this in prototype framework ?
i.e. I tried to do this but doesn’t work
Event.observe(window, ‘load’,
function() {var url = document.location.href;
if (url.indexOf(‘registered’) >=
0) {
$$(‘#side-menu-right’).hide(); }if (url.indexOf(‘login’) >= 0)
{ $$(‘#side-menu-left’).hide();
}});
Love some help ?
P.S – Never used Prototype [jQuery man right here yo!]
I just made a test case on JS Bin which complains:
(using latest version of Prototype)
When using:
it works correctly, see example.
EDIT: I adjusted the example on JS Bin to conditionally add a class name to the
bodybefore the involved element is reached. UsingThe element doesn’t show up at all. It’s not the most neat solution, as you have to throw some
scriptin the middle of your document, but it works. If someone knows a better solution, please tell.