Page 1 of 2 12 LastLast
Results 1 to 10 of 19

Thread: Urgent Help!!

  1. #1
    Join Date
    Oct 2006
    Posts
    40
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Exclamation Urgent Help!!

    Hi,

    Hopefully someone can help me here.

    Without saying too much, I have a slide show script thats written in Javascript and some DHTML. I got it from a site:

    Code:
    <style type="text/css">
    .slide {
       position: absolute;
       visibility : hidden;
    }
    #slide0 {
       visibility : visible;
    }
     </style>
    <script type="text/javascript">
    //Browser check
    var DHTML = (document.getElementById || document.all || document.layers);
    if ( !DHTML ) alert('Your browser is not capable of displaying DHTML');
    function getObj(name) {
    	if (document.getElementById) {
    		this.style = document.getElementById(name).style;
    	} else
    	if (document.all) {
    		this.style = document.all[name].style;
    	} else
    	if (document.layers) {
    		this.style = document.layers[name];
    	}
    }
    
    //Switch elements visible or hidden
    function visib(objName, flag) {
    	x = new getObj(objName);
    	x.style.visibility = (flag) ? 'visible' : 'hidden';
    }
    
    //Switch next element visible and previous hidden.
    var curImg = 0; // index of the array entry
    var lastImg = 0;
    
    function changeSlide ( change ) {
    	if (!DHTML) return;
    	curImg += change;
    	if ( curImg < 0 ) curImg = slides.length-1;
    	else
    		if ( curImg >= slides.length ) curImg = 0;
    
    	visib(slides[lastImg], false);
    	visib(slides[curImg], true);
    	lastImg = curImg;
    }
    //Array containing all element names (== pictures)
    slides = new Array(
    	'slide0',
    	'slide1',
    	'slide2');
    Then in the body I have it like such:

    <a href="javascript:changeSlide(-1);" class="ftm_next">Previous</a>&nbsp;|&nbsp;<a href="javascript:changeSlide(1)" class="ftm_next">Next</a>
    <span id="slide0" class="slide" style="width: 380px;">blah blah</span>
    <span id="slide1" class="slide" style="width: 380px;">blah blah blah</span>
    <span id="slide2" class="slide" style="width: 380px;">blah blah blah blah</span>
    Everything is fine, except for a few issues:

    1. I want to make it look like MSN, and have it automatically slide instead of just using the next and forward buttons.
    2. I want the auto slider function to stop if the person uses the previous/next link.
    3. If its possible, I would like a fade in and fade out too.


    The slide show will contain images in a table and some news text, pretty much like MSN.

    Thanks in advance to all those JS gurus!

    AK7861

  2. #2
    Join Date
    May 2006
    Location
    Sydney, Australia - Near the coast.
    Posts
    1,995
    Thanks
    0
    Thanked 8 Times in 7 Posts

    Default

    Like this?

    Code:
    <html>
    
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=windows-1252">
    <title>Previous | Next blah blah blah b</title>
    
    <style type="text/css">
    .slide {
       position: absolute;
       visibility : hidden;
    }
    #slide0 {
       visibility : visible;
    }
     </style>
    <script type="text/javascript">
    //Browser check
    var DHTML = (document.getElementById || document.all || document.layers);
    if ( !DHTML ) alert('Your browser is not capable of displaying DHTML');
    function getObj(name) {
    	if (document.getElementById) {
    		this.style = document.getElementById(name).style;
    	} else
    	if (document.all) {
    		this.style = document.all[name].style;
    	} else
    	if (document.layers) {
    		this.style = document.layers[name];
    	}
    }
    
    //Switch elements visible or hidden
    function visib(objName, flag) {
    	x = new getObj(objName);
    	x.style.visibility = (flag) ? 'visible' : 'hidden';
    }
    
    //Switch next element visible and previous hidden.
    var curImg = 0; // index of the array entry
    var lastImg = 0;
    
    function changeSlide ( change ) {
    	if (!DHTML) return;
    	curImg += change;
    	if ( curImg < 0 ) curImg = slides.length-1;
    	else
    		if ( curImg >= slides.length ) curImg = 0;
    
    	visib(slides[lastImg], false);
    	visib(slides[curImg], true);
    	lastImg = curImg;
    }
    
    var sec = 1 //Auto-Slide Intervals
    var stopped = 0
    var auto = setInterval("changeSlide(1)",sec*1000)
    
    function stopSlide()	{
    
    	if (stopped==0)	{
    	stopped==1
    	clearInterval(auto)
    	}
    }
    //Array containing all element names (== pictures)
    slides = new Array(
    	'slide0',
    	'slide1',
    	'slide2')
    </script>
    </head>
    
    <body>
    <a href="javascript:stopSlide();changeSlide(-1);" class="ftm_next">Previous</a>&nbsp;|&nbsp;<a href="javascript:stopSlide();changeSlide(1)" class="ftm_next">Next</a>
    <span id="slide0" class="slide" style="width: 380px;">blah blah</span>
    <span id="slide1" class="slide" style="width: 380px;">blah blah blah</span>
    <span id="slide2" class="slide" style="width: 380px;">blah blah blah blah</span>
    </body>
    
    </html>
    (The changes are in bold)

    Sorry, will do fade in later.

    Or do you want it to actually slide

    Edit: Compatibility Issue with Internet Explorer.
    Last edited by tech_support; 10-09-2006 at 03:42 AM. Reason: Compatibility Issues
    Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
    Currently: enjoying the early holidays :)
    Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide

  3. #3
    Join Date
    Oct 2006
    Posts
    40
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Thanks a bunch!! But it doesn't work for me on mozilla. Any idea?

  4. #4
    Join Date
    Oct 2006
    Posts
    40
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Oh, i got it to work for mozilla now. Just had to add a loder on the body tag. Thanks once again!!

    Looking forward to the fade in and fade out!

  5. #5
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    NOTE: I hate off topic titles. "Urgent help" has nothing to do with your question. If you title it even something like the generic "help with script", it just makes it a bit clearer. Something like "help with slide show fading" would be great.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  6. #6
    Join Date
    Oct 2006
    Posts
    40
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    No problem. Will try to remember that next time.

    One more thing. Is there any way to get rid of that position: absolute value in the css and still get the same view for the slide show? Because its conflicting with my other css scripts.

    Thanks.

  7. #7
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Hmm... not sure. There must be a way to modify it. But not sure exactly how.
    just getting rid of it is wrong because it does something. Either replacing it or modifying it would be best. I'd suggest modifying the location so it doesn't conflict.
    Link to your page or post the source. What is the "conflict" with the other css?
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  8. #8
    Join Date
    Oct 2006
    Posts
    40
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Actually it's not conflicting with the css, but the problem is since its kept "absolute" the tables surrounding it appear empty, until i add height. I guess if we change visible to hide, and hidden to block, it would solve the problem. Anyone can help me with that?

  9. #9
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,164
    Thanks
    265
    Thanked 690 Times in 678 Posts

    Default

    Sorry, but this isn't my area. Perhaps someone else will be able to.
    Daniel - Freelance Web Design | <?php?> | <html>| español | Deutsch | italiano | português | català | un peu de français | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

  10. #10
    Join Date
    May 2006
    Location
    Sydney, Australia - Near the coast.
    Posts
    1,995
    Thanks
    0
    Thanked 8 Times in 7 Posts

    Default

    ak7861 says (via PM) that this doesn't work in Internet Explorer. Any clues?
    Peter - alotofstuffhere[dot]com - Email Me - Donate via PayPal - Got spare hardware? Donate 'em to me :) Just send me a PM.
    Currently: enjoying the early holidays :)
    Read before posting: FAQ | What you CAN'T do with JavaScript | Form Rules | Thread Title Naming Guide

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •