[Proto-Scripty] Re: Slider doesn't work anymore?
Or, you can load the js files after you html > body is loaded/parsed. It's a good practice (IMO). http://www.w3.org/1999/xhtml";> My testing page On Thu, Jul 16, 2009 at 1:54 PM, ColinFine wrote: > > > > On Jul 16, 1:22 am, "bambell...@hotmail.com" > wrote: >> I've made a quick search on Google and realised it's because the >> sliders are being created before the HTML elements are initialised (as >> script.js loads in the header). >> I used a setTimeout and it now works fine! Thanks anyways! > > A *much* better approach is to use an event, and Prototype provides > one specially for you: > > document.observe('dom:loaded', function () { > // Any code that depends on the DOM being completely loaded > }) > > > -- Believe nothing, no matter where you read it, or who said it, no matter if I have said it, unless it agrees with your own reason and your own common sense. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Slider doesn't work anymore?
On Jul 16, 1:22 am, "bambell...@hotmail.com" wrote: > I've made a quick search on Google and realised it's because the > sliders are being created before the HTML elements are initialised (as > script.js loads in the header). > I used a setTimeout and it now works fine! Thanks anyways! A *much* better approach is to use an event, and Prototype provides one specially for you: document.observe('dom:loaded', function () { // Any code that depends on the DOM being completely loaded }) --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Slider doesn't work anymore?
I've made a quick search on Google and realised it's because the sliders are being created before the HTML elements are initialised (as script.js loads in the header). I used a setTimeout and it now works fine! Thanks anyways! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Slider doesn't work anymore?
Thank you very much for the reply T.J. Crowder. I don't want to make it impossible to understand (obfuscate), as you said, it wouldn't be well spent time in my case. All I want is to remove the Javascript from the source page (right click -> View Source) so comon people wouldn't see it. I also find it makes developing the website much more convenient to have HTML and Javascript in separated files. As I said, it was working perfectly before the change. All I did for script.js is to move the whole Javascript code from the javascript tag (excluding it, so script.js starts with my code and end with it). I forgot to say Firefox tells me "this.track is null" in line 171 of slider.js. Here is how I create one of the sliders in script.js: var c_level_slider = new Control.Slider( $( 'current_level_handle' ), $ ( 'current_level_track' ), { range: $R( 1, 100 ), values: $R( 1, 100 ), onSlide: function( value ) { ... }, onChange: function( value ) { ... } }); If you have any clues that's wrong...please let me know, I'm really stuck on this. Thanks again. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---
[Proto-Scripty] Re: Slider doesn't work anymore?
Hi, > As I don't want the whole code to be visible to everyone, I tried > splitting the HTML from the Javascript. That doesn't change anything, anyone who wants to see it can still see the JavaScript. They have to look a *little* harder, but it's trivial to look at the HTML, see the script tag with the src in it, and figure out the URL to that file. If you want to spend time doing web server config, you can prevent requests for that file that don't have the "referer" set to the HTML file it's in, but that just brings its own trouble and eats time better spent doing something else. > Would someone please be able to point me out what's the problem or an > other way to hide Javascript? I don't see any problem with what you have provided script.js is where it needs to be and contains exactly what you used to have within the script tag in the HTML. But again, you can't hide the JavaScript. You can obfuscate[1] it, but if the code is delivered to the browser (which it has to be to be run), then the end user can see it if they want to. [1] http://en.wikipedia.org/wiki/Obfuscated_code FWIW, -- T.J. Crowder tj / crowder software / com Independent Software Engineer, consulting services available On Jul 15, 9:07 pm, "bambell...@hotmail.com" wrote: > Hi, > > I nearly finished a project which heavily use Script.Aculo.Us's > effects and sliders. Everything worked fine. > I have eveything into an index.html file, execpt the CSS stylesheet. > As I don't want the whole code to be visible to everyone, I tried > splitting the HTML from the Javascript. I created a file Index.php and > put all the HTML in it and a file called script.js where all the > Javascript is. > > Since I made this change, the sliders doesn't work anymore (can't be > slided). > > Would someone please be able to point me out what's the problem or an > other way to hide Javascript? > > Index.php starts with: > > $to_print .= << "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd";> > http://www.w3.org/1999/xhtml";> > > > > > > @import url(style.css); > > > > > ... And end with: > > > > > HTML; > > print $to_print; > > ?> --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to prototype-scriptaculous@googlegroups.com To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en -~--~~~~--~~--~--~---