How to create an SlideShow in javascript?

Can I add a javascript slideshow to my website articles even if Im using a proprietary CMS?

  • Can I add a javascript slideshow to my website articles even if Im using a proprietary CMS? I am building my company's (a magazine) website in a proprietary CMS from a company I dont want to name. The reason I am asking you guys instead of them is because it takes forever to get a satisfactory answer over there and they tend to be steering me towards options Im not always too keen on and that arent as customizable as I'd like them to be. What I am wondering is, since each article I place thru this CMS allows me to toggle over and mess with the SOURCE to better edit and build the article, is it possible to use a javascript slideshow (like say http://www.thedaily.com/page/2012/02/05/020512-news-detroit-vigilantes-1-5/, which I rather like) even though I would probably have to place it manually on every single page? We are a very photo-heavy magazine and I'd rather not have to minefield these pix throughout each story and this slideshow seems like an elegant solution to that.

  • Answer:

    Hard to say without knowing the CMS, but unlikely. Every CMS editor I have ever seen strips javascript and most html for that matter. But the nest way to find out is to just try and see. Add a little JS into the editor, hit "save" and see if it gets saved or stripped out.

Senor Cardgage at Ask.Metafilter.Com Visit the source

Was this solution helpful to you?

Other answers

It would depend on the specifics of the CMS, but if the Javascript does not get stripped then theoretically it should work. Of course you might be placing your JS in odd places on your page, so the code is going to look a mess - also whatever code you are writing will have to accommodate that. Do you want to hear all the reasons why this may be bad practice and difficult to maintain? :-)

Artw

Sure. Shoot.

Senor Cardgage

Well, as I say, the code will be ugly, for a start, which may or may not be a problem to you since it's under-the-hood, but it would bother me and It's the sort of thing that, if bad enough, can make pages horrible to work with. Since your JS is not in a separate file it won't cache and it will have to be reloaded for each page it's on, which will bloat your site. Also, since you will have to insert the same JavaScript into the CMS multiple times you are setting yourself up for maintenance problems, basically whenever you change it at all you are going to make sure they are are all updated to match or you'll have a confusing mess.

Artw

Yeah. Thought so. Gah, the horror of the third party slideshow they have available for me to use.

Senor Cardgage

*If* you can add JavaScript to the header of *all* your pages then this might not be too bad. If the existing CMS includes JavaScript you may be able to add to that, and then create your slideshows by adding a group of photos to a story like <div class="customSlideshow"><img><img><img> The JavaScript you added to your header might include jQuery, MooTools, or Prototype or whatever, and then turn that .customSlideshow into an area that has all the proper slideshow behaviors by modifying the code. A well written piece of JS will fire when one or more elements with the class customSlideshow is on the page. This is all incredibly speculative, but that's how I'd be thinking about this.

artlung

Of course, if you can get your CMS to upload a .js file somewhere you can get to it, then use your script tags to link to it rather than to contain inline Javascript, you will be in a much better position.

Artw

Well wait, we have a js folder set up thru the CMS company. Couldnt I just load the relevant scripts there and call them up on the page? (Note, Im sorta new at all this)

Senor Cardgage

If you can put your slideshow script file in there and then call it from your page you'll be in fairly good shape, yes.

Artw

If I can do this without crashing the entirety of the North American webzone, then I shall be a hero. Hmmmmmm

Senor Cardgage

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.