www.webdeveloper.com
Results 1 to 4 of 4

Thread: scroll an html content in a javascript slider

  1. #1
    Join Date
    Aug 2013
    Posts
    2

    scroll an html content in a javascript slider

    I have a web content slider and i want it to scroll html pages that are displayed and loaded in one page i found a function who does it but it appears that it doesn't work can someone please help me with it this my code:

    <html>
    <head>
    <title>SiteShow 1.0</title>
    <meta http-equiv="content-type" content="text/html; charset=windows-1250">
    <style>
    /* Change body background-color to change fade out color. */
    /*body.siteshow { margin:0; padding:0; background-color:#000000;}*/
    #menu
    {
    font-family:Arial;
    font-size:9pt;
    display:none;
    opacity:0.00;
    -mozopacity:0.00;
    filter:alpha(opacity=0);
    position:absolute;
    top:10px;
    left:10px;
    padding:5px;
    background-color:#000000;
    color:#FFFFFF;
    border:3px dotted #999999;
    }
    #menu a { color:#ffffff; }
    #menu a:hover { text-decoration:none; }
    #title { font-size:11pt; font-weight:bold; letter-spacing:2; }
    #slides { font-size:9pt; line-height:16pt; }
    .button { width:60px; font-size:9pt; letter-spacing:1; }
    #bottom {
    border: 1px solid red;
    }
    </style>

    <script type="text/javascript">
    var current_idx = 0;
    var slides = new Array();
    var menuwin;
    var show_timer;
    var menu_timer;
    var menu;
    var content;
    var loaded = true;
    // Define your "slides". 3 values for each are:
    // 1. Duration in seconds.
    // 2. Title to be used in menu.
    // 3. Source URL. Can be full URI or a relative URL.
    slides[1] = new Array(15, "Hespress", "http://www.hespress.com");
    slides[2] = new Array(15, "Hihi2", "http://www.hihi2.com");
    slides[3] = new Array(15, "Realitylapse", "http://www.realitylapse.com");
    slides[4] = new Array(15, "kooora", "http://www.kooora.com");

    ScrollRate = 100;

    function scrollDiv_init() {
    DivElmnt = document.getElementById('slides');
    ReachedMaxScroll = false;

    DivElmnt.scrollTop = 0;
    PreviousScrollTop = 0;

    ScrollInterval = setInterval('scrollDiv()', ScrollRate);
    }

    function scrollDiv() {

    if (!ReachedMaxScroll) {
    DivElmnt.scrollTop = PreviousScrollTop;
    PreviousScrollTop++;

    ReachedMaxScroll = DivElmnt.scrollTop >= (DivElmnt.scrollHeight - DivElmnt.offsetHeight);
    }
    else {
    ReachedMaxScroll = (DivElmnt.scrollTop == 0)?false:true;

    DivElmnt.scrollTop = PreviousScrollTop;
    PreviousScrollTop--;
    }
    }

    function pauseDiv() {
    clearInterval(ScrollInterval);
    }

    function resumeDiv() {
    PreviousScrollTop = DivElmnt.scrollTop;
    ScrollInterval = setInterval('scrollDiv()', ScrollRate);
    }


    function MenuInit()
    {
    var html = "";
    for(idx=1; idx<slides.length; idx++) {
    html += '<a href="javascript:Navigate('+idx+')">' +
    slides[idx][1] + "</a><br />\n";
    }
    document.getElementById("slides").innerHTML = html;

    menu.style.display = "block";
    }
    function MenuShow()
    {
    clearTimeout(menu_timer);
    opacity('menu', 0, 90, 500);
    menu_timer = setTimeout("MenuHide()", 3500);
    }
    function MenuHide()
    {
    opacity('menu', 90, 0, 500);
    }
    function Pause()
    {
    clearTimeout(show_timer);
    document.getElementById('play').style.display = "block";
    document.getElementById('pause').style.display = "none";
    }
    function Navigate(slide_idx)
    {
    clearTimeout(show_timer);
    if (current_idx == 0) {
    if (!slide_idx) { slide_idx = 1; }
    current_idx = slide_idx;
    content.src = slides[current_idx][2];
    document.getElementById('play').style.display = "none";
    document.getElementById('pause').style.display = "block";
    show_timer = setTimeout("Navigate()", slides[current_idx][0]*1000);
    return;
    }
    if (slide_idx) {
    current_idx = slide_idx;
    content.src = slides[current_idx][2];
    document.getElementById('play').style.display = "block";
    document.getElementById('pause').style.display = "none";
    return;
    }
    loaded = false;
    current_idx++;
    if ( current_idx == slides.length) { current_idx = 1; }
    opacity('content', 100, 0, 500);
    document.getElementById('play').style.display = "none";
    document.getElementById('pause').style.display = "block";
    show_timer = setTimeout("Navigate()", slides[current_idx][0]*1000);
    return;
    }
    function opacity(id, opacStart, opacEnd, millisec)
    {
    //speed for each frame
    var speed = Math.round(millisec / 100);
    var timer = 0;
    //determine the direction for the blending, if start and end are the same nothing happens
    if(opacStart > opacEnd) {
    for(i = opacStart; i >= opacEnd; i--) {
    setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
    timer++;
    }
    if (opacEnd == 0) { setTimeout("FadeOutTrigger('"+id+"')",((timer-1) * speed));; }
    //if (opacEnd == 0) { FadeOutTrigger(id); }
    } else if(opacStart < opacEnd) {
    if (opacStart == 0) { FadeInTrigger(id); }
    for(i = opacStart; i <= opacEnd; i++)
    {
    setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
    timer++;
    }
    }
    }
    //change the opacity for different browsers
    function changeOpac(opacity, id)
    {
    var object = document.getElementById(id).style;
    object.opacity = (opacity / 100);
    object.MozOpacity = (opacity / 100);
    object.KhtmlOpacity = (opacity / 100);
    object.filter = "alpha(opacity=" + opacity + ")";
    }
    function FadeOutTrigger(id)
    {
    //alert('FadeOut: '+id);
    switch(id) {
    case "menu":
    document.getElementById(id).style.display = "none";
    break;
    case "content":
    content.src = slides[current_idx][2];
    //setTimeout("opacity('content', 0, 100, 500)", 1000);
    break;
    case "element":
    var ele = document.getElementById(element);
    window.scrollTo(ele.offsetLeft,ele.offsetTop);
    default:
    break;
    }
    }
    function FadeInTrigger(id)
    {
    //alert('FadeIn: '+id);
    switch(id) {
    case "menu":
    document.getElementById(id).style.display = "block";
    break;
    case "content":
    //opacity('content', 0, 100, 500);
    break;
    default:
    break;
    }
    }
    function FadeInContent()
    {
    if (!loaded) {
    opacity('content', 0, 100, 500);
    loaded = true;
    }
    }
    function LoadTrigger()
    {
    //self.resizeTo(1366,768);
    menu = document.getElementById('menu');
    content = document.getElementById('content');

    Navigate();
    MenuInit();
    MenuShow();

    }
    window.onload = LoadTrigger;







    </script>

    </head>

    <body class="siteshow" onLoad="scrollDiv_init()" >
    <iframe id="content" name="content" style="width:100%; height:100%;" frameborder="no" scrolling="auto" src="" onmouseover="MenuShow();" onload="FadeInContent();" ></iframe>
    <div id="menu">
    <div id="title">SiteShow Menu</div>
    <div id="slides" onMouseOver="pauseDiv()" onMouseOut="resumeDiv()">
    </div>
    <p>
    <input id="pause" class="button" style="display:block;" type="button" value="pause" onclick="Pause()" />
    <input id="play" class="button" style="display:none;" type="button" value="play" onclick="Navigate()" />
    </p>
    </div>

    </body>
    </html>


    N.B : If you have any problem displaying the code you need to remove onload from the body.

  2. #2
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,716
    try this

    Code:
    <html>
     <head>
     <title>SiteShow 1.0</title>
     <meta http-equiv="content-type" content="text/html; charset=windows-1250">
     <style>
     /* Change body background-color to change fade out color. */
     /*body.siteshow { margin:0; padding:0; background-color:#000000;}*/
     #menu
     {
     font-family:Arial;
     font-size:9pt;
     display:none;
     opacity:0.00;
     -mozopacity:0.00;
     filter:alpha(opacity=0);
     position:absolute;
     top:10px;
     left:10px;
     padding:5px;
     background-color:#000000;
     color:#FFFFFF;
     border:3px dotted #999999;
     }
     #menu a { color:#ffffff; }
     #menu a:hover { text-decoration:none; }
     #title { font-size:11pt; font-weight:bold; letter-spacing:2; }
     #slides { font-size:9pt; line-height:16pt; }
     .button { width:60px; font-size:9pt; letter-spacing:1; }
     #bottom {
     border: 1px solid red;
     }
     </style>
    
     <script type="text/javascript">
     var current_idx = 0;
     var slides = new Array();
     var menuwin;
     var show_timer;
     var menu_timer;
     var menu;
     var content;
     var loaded = true;
     // Define your "slides". 3 values for each are:
     // 1. Duration in seconds.
     // 2. Title to be used in menu.
     // 3. Source URL. Can be full URI or a relative URL.
     slides[1] = new Array(15, "Hespress", "http://www.hespress.com");
     slides[2] = new Array(15, "Hihi2", "http://www.hihi2.com");
     slides[3] = new Array(15, "Realitylapse", "http://www.realitylapse.com");
     slides[4] = new Array(15, "kooora", "http://www.kooora.com");
    
     ScrollRate = 100;
    
     function scrollDiv_init() {
     DivElmnt = document.getElementById('slides');
     ReachedMaxScroll = false;
    
     DivElmnt.scrollTop = 0;
     PreviousScrollTop = 0;
    
     ScrollInterval = setInterval('scrollDiv()', ScrollRate);
     }
    
     function scrollDiv() {
    
     if (!ReachedMaxScroll) {
     DivElmnt.scrollTop = PreviousScrollTop;
     PreviousScrollTop++;
    
     ReachedMaxScroll = DivElmnt.scrollTop >= (DivElmnt.scrollHeight - DivElmnt.offsetHeight);
     }
     else {
     ReachedMaxScroll = (DivElmnt.scrollTop == 0)?false:true;
    
     DivElmnt.scrollTop = PreviousScrollTop;
     PreviousScrollTop--;
     }
     }
    
     function pauseDiv() {
     clearInterval(ScrollInterval);
     }
    
     function resumeDiv() {
     PreviousScrollTop = DivElmnt.scrollTop;
     ScrollInterval = setInterval('scrollDiv()', ScrollRate);
     }
    
    
     function MenuInit()
     {
     var html = "";
     for(idx=1; idx<slides.length; idx++) {
     html += '<a href="javascript:Navigate('+idx+')">' +
     slides[idx][1] + "</a><br />\n";
     }
     document.getElementById("slides").innerHTML = html;
    
     menu.style.display = "block";
     }
     function MenuShow()
     {
     clearTimeout(menu_timer);
     opacity('menu', 0, 90, 500);
     menu_timer = setTimeout("MenuHide()", 3500);
     }
     function MenuHide()
     {
     opacity('menu', 90, 0, 500);
     }
     function Pause()
     {
     clearTimeout(show_timer);
     document.getElementById('play').style.display = "block";
     document.getElementById('pause').style.display = "none";
     }
     function Navigate(slide_idx)
     {
     clearTimeout(show_timer);
     if (current_idx == 0) {
     if (!slide_idx) { slide_idx = 1; }
     current_idx = slide_idx;
     content.src = slides[current_idx][2];
     document.getElementById('play').style.display = "none";
     document.getElementById('pause').style.display = "block";
     show_timer = setTimeout("Navigate()", slides[current_idx][0]*1000);
     return;
     }
     if (slide_idx) {
     current_idx = slide_idx;
     content.src = slides[current_idx][2];
     document.getElementById('play').style.display = "block";
     document.getElementById('pause').style.display = "none";
     return;
     }
     loaded = false;
     current_idx++;
     if ( current_idx == slides.length) { current_idx = 1; }
     opacity('content', 100, 0, 500);
     document.getElementById('play').style.display = "none";
     document.getElementById('pause').style.display = "block";
     show_timer = setTimeout("Navigate()", slides[current_idx][0]*1000);
     return;
     }
     function opacity(id, opacStart, opacEnd, millisec)
     {
     //speed for each frame
     var speed = Math.round(millisec / 100);
     var timer = 0;
     //determine the direction for the blending, if start and end are the same nothing happens
     if(opacStart > opacEnd) {
     for(i = opacStart; i >= opacEnd; i--) {
     setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
     timer++;
     }
     if (opacEnd == 0) { setTimeout("FadeOutTrigger('"+id+"')",((timer-1) * speed));; }
     //if (opacEnd == 0) { FadeOutTrigger(id); }
     } else if(opacStart < opacEnd) {
     if (opacStart == 0) { FadeInTrigger(id); }
     for(i = opacStart; i <= opacEnd; i++)
     {
     setTimeout("changeOpac(" + i + ",'" + id + "')",(timer * speed));
     timer++;
     }
     }
     }
     //change the opacity for different browsers
     function changeOpac(opacity, id)
     {
     var object = document.getElementById(id).style;
     object.opacity = (opacity / 100);
     object.MozOpacity = (opacity / 100);
     object.KhtmlOpacity = (opacity / 100);
     object.filter = "alpha(opacity=" + opacity + ")";
     }
     function FadeOutTrigger(id)
     {
     //alert('FadeOut: '+id);
     switch(id) {
     case "menu":
     document.getElementById(id).style.display = "none";
     break;
     case "content":
     content.src = slides[current_idx][2];
     //setTimeout("opacity('content', 0, 100, 500)", 1000);
     break;
     case "element":
     var ele = document.getElementById(element); 
     window.scrollTo(ele.offsetLeft,ele.offsetTop);
     default:
     break;
     }
     }
     function FadeInTrigger(id)
     {
     //alert('FadeIn: '+id);
     switch(id) {
     case "menu":
     document.getElementById(id).style.display = "block";
     break;
     case "content":
     //opacity('content', 0, 100, 500);
     break;
     default:
     break;
     }
     }
     function FadeInContent()
     {
     if (!loaded) {
     opacity('content', 0, 100, 500);
     loaded = true;
     }
     }
     function LoadTrigger()
     {
     //self.resizeTo(1366,768);
     menu = document.getElementById('menu');
     content = document.getElementById('content');
    
     Navigate();
     MenuInit();
     MenuShow();
    scrollDiv_init();
     }
     window.onload = LoadTrigger;
    
    
    
    
    
    
    
     </script>
    
     </head>
    
     <body class="siteshow">
     <iframe id="content" name="content" style="width:100%; height:100%;" frameborder="no" scrolling="auto" src="" onmouseover="MenuShow();" onload="FadeInContent();" ></iframe>
     <div id="menu">
     <div id="title">SiteShow Menu</div>
     <div id="slides" onMouseOver="pauseDiv()" onMouseOut="resumeDiv()">
     </div>
     <p>
     <input id="pause" class="button" style="display:block;" type="button" value="pause" onclick="Pause()" />
     <input id="play" class="button" style="display:none;" type="button" value="play" onclick="Navigate()" />
     </p>
     </div>
    
     </body>
     </html>
    signature under construction

  3. #3
    Join Date
    Aug 2013
    Posts
    2
    I tried already this possibility but it didn't work.did it work for you padonak ? thanks

  4. #4
    Join Date
    May 2006
    Location
    Somewhere behind your screen
    Posts
    1,716
    i think it did at least in Opera, FF and Safari. to a pity my internet connection is very slow (3G flash modem) and the pages change faster than they're fully loaded. i hope it works ok for those who have better internet connection
    signature under construction

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

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

"

"

X vBulletin 4.2.2 Debug Information

  • Page Generation 0.16852 seconds
  • Memory Usage 2,911KB
  • Queries Executed 15 (?)
More Information
Template Usage (33):
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_global_above_footer
  • (1)ad_global_below_navbar
  • (1)ad_global_header1
  • (1)ad_global_header2
  • (1)ad_navbar_below
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)ad_thread_first_post_content
  • (1)ad_thread_last_post_content
  • (1)bbcode_code
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)headinclude_bottom
  • (4)memberaction_dropdown
  • (1)navbar
  • (4)navbar_link
  • (1)navbar_moderation
  • (1)navbar_noticebit
  • (1)navbar_tabs
  • (2)option
  • (4)postbit
  • (4)postbit_onlinestatus
  • (4)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available (6):
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files (26):
  • ./showthread.php
  • ./global.php
  • ./includes/class_bootstrap.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/functions_navigation.php
  • ./includes/class_friendly_url.php
  • ./includes/class_hook.php
  • ./includes/class_bootstrap_framework.php
  • ./vb/vb.php
  • ./vb/phrase.php
  • ./includes/functions_facebook.php
  • ./includes/functions_calendar.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_notice.php
  • ./packages/vbattach/attach.php
  • ./vb/types.php
  • ./vb/cache.php
  • ./vb/cache/db.php
  • ./vb/cache/observer/db.php
  • ./vb/cache/observer.php 

Hooks Called (72):
  • init_startup
  • friendlyurl_resolve_class
  • init_startup_session_setup_start
  • database_pre_fetch_array
  • database_post_fetch_array
  • init_startup_session_setup_complete
  • global_bootstrap_init_start
  • global_bootstrap_init_complete
  • cache_permissions
  • fetch_postinfo_query
  • fetch_postinfo
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • load_show_variables
  • load_forum_show_variables
  • global_state_check
  • global_bootstrap_complete
  • global_start
  • style_fetch
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • strip_bbcode
  • friendlyurl_clean_fragment
  • friendlyurl_geturl
  • forumjump
  • cache_templates
  • cache_templates_process
  • template_register_var
  • template_render_output
  • fetch_template_start
  • fetch_template_complete
  • parse_templates
  • fetch_musername
  • notices_check_start
  • notices_noticebit
  • process_templates_complete
  • friendlyurl_redirect_canonical
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • memberaction_dropdown
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • build_navigation_data
  • build_navigation_array
  • check_navigation_permission
  • process_navigation_links_start
  • process_navigation_links_complete
  • set_navigation_menu_element
  • build_navigation_menudata
  • build_navigation_listdata
  • build_navigation_list
  • set_navigation_tab_main
  • set_navigation_tab_fallback
  • navigation_tab_complete
  • fb_like_button
  • showthread_complete
  • page_templates