/    Sign up×
Community /Pin to ProfileBookmark

Slideshow with large slides

I have been trying to develop a slideshow with large slides. I’d like it to work in all later browsers work with both jpgs and swfs. be able to update the slides as they get changed. I had the idea of loading all in iframes and hiding and showing iframes here is the code so far

[code]
<!doctype html>
<html>
<head>
<title>
Hidden Iframe Slideshow
</title>
<script>
var item=0,prev=0;
var myWidth;
var myHeight;
var timeouts;

function next()
{
document.getElementById(prev).height=0;
document.getElementById(prev).width=0;
document.getElementById(prev).contentDocument.location.reload(true);
if(item>=window.frames.length){item=0;}
document.getElementById(item).height=myHeight+”px”;
document.getElementById(item).width=myWidth+”px”;
prev=item;
setTimeout(“next()”,timeouts[item]);
item++;
}

function init()
{
if( typeof( window.innerWidth ) == ‘number’ )
{//Non-IE
myWidth = window.innerWidth;
myHeight = window.innerHeight;
}
else if( document.documentElement && (document.documentElement.clientWidth||document.documentElement.clientHeight))
{//IE 6+ in ‘standards compliant mode
myWidth = document.documentElement.clientWidth;
myHeight = document.documentElement.clientHeight;
}
else if(document.body&&(document.body.clientWidth||document.body.clientHeight))
{//IE 4 compatible
myWidth = document.body.clientWidth;
myHeight = document.body.clientHeight;
}
images=new Array(“http://www.mvdwebexpress.com/adsImages/MCGINNIS.swf”,”http://www.mvdwebexpress.com/adsImages/RocktheboatAD.jpg”,”http://www.mvdwebexpress.com/adsImages/New_Hires_In_Offices.jpg”);
timeouts=new Array(18000,6000,6000);
for(item=0;item<window.frames.length;item++)
{
window.frames[item].document.open();
if(images[item].substr(-3).toLowerCase()==”jpg”)
{
window.frames[item].document.write(“<html><head></head><body><img height=100% width=100% src=”+images[item]+”></body></html>”);
}
else
{
window.frames[item].document.write(“<html><head></head><body><embed height=100% width=100% src=”+images[item]+”></embed></body></html>”);
}
window.frames[item].document.close();
}
item=0;
next();
}
</script>
<style>
body {
overflow: hidden;
}
</style>
</head>
<body onload=”init()”>
<div style=”position:absolute;top:0;left:0″>
<iframe id=”0″ height=0 width=0 frameborder=0 marginheight=0 marginwidth=0 scrolling=no></iframe>
</div>
<div style=”position:absolute;top:0;left:0″>
<iframe id=”1″ height=0 width=0 frameborder=0 marginheight=0 marginwidth=0 scrolling=no></iframe>
</div>
<div style=”position:absolute;top:0;left:0″>
<iframe id=”2″ height=0 width=0 frameborder=0 marginheight=0 marginwidth=0 scrolling=no></iframe>
</div>
</body>
</html>
[/code]

Current issues:
IE: some images still load when I unhide the iframe. (not bad)
Firefox: when reloading a slide in the background it displays a message at the bottom of the screen
Chrome: It displays a white box over all slides making it useless.(found this out by changing the frameborder)

The reason I chose the iframe method was I had previous good experiences getting iframes to hide and unhide using javascript in the past. Also I figured if all the slides are loaded in their frames they should display instantly when the frame is unhidden(no need to download). The only reason firefox displays the message is because of the document.getElementById(prev).contentDocument.location.reload(true);
which I do to look for updates to the image is there a way with ajax to tell if the image was updated?
Is there a simple fix for chrome?
Is there a better html/javascript method to do what I’d like to do.
Remember these are large slides so it takes time to reget each image; longer than the time I want to display the slides for. It is required that some slides be in the jpg format and that some are swf files.

to post a comment
HTML

2 Comments(s)

Copy linkTweet thisAlerts:
@jeffsadowskiauthorJul 20.2012 — I redid it once more and it seems to be happy I'll have to try and change an image and see if it grabs the new image. Current version is bellow.
<i>
</i>&lt;!doctype html&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta charset="UTF-8"&gt;
&lt;title&gt;
Hidden Iframe Slideshow
&lt;/title&gt;
&lt;style&gt;
body { cursor:none;overflow:hidden; }
.nocursor { cursor:none;position:absolute;top:0;left:0; }
&lt;/style&gt;
&lt;script&gt;
var item=0,prev=0;
var myWidth;
var myHeight;
var timeouts;


function next()
{
document.getElementById(prev).height=0;
document.getElementById(prev).width=0;
// document.getElementById(prev).contentDocument.location.reload(true);
if(item&gt;=window.frames.length){item=0;}
document.getElementById(item).height=myHeight+"px";
document.getElementById(item).width=myWidth+"px";
prev=item;
setTimeout("next()",timeouts[item]);
item++;
}

function init()
{
try
{
if( typeof( window.innerWidth ) == 'number' )
{//Non-IE
myWidth = window.innerWidth;
myHeight = window.innerHeight;
}
else if( document.documentElement &amp;&amp; (document.documentElement.clientWidth||document.documentElement.clientHeight))
{//IE 6+ in 'standards compliant mode
myWidth = document.documentElement.clientWidth;
myHeight = document.documentElement.clientHeight;
}
else if(document.body&amp;&amp;(document.body.clientWidth||document.body.clientHeight))
{//IE 4 compatible
myWidth = document.body.clientWidth;
myHeight = document.body.clientHeight;
}
images=new Array("http://www.mvdwebexpress.com/adsImages/MCGINNIS.swf","http://www.mvdwebexpress.com/adsImages/RocktheboatAD.jpg","http://www.mvdwebexpress.com/adsImages/New_Hires_In_Offices.jpg");
timeouts=new Array(18000,6000,6000);
for(item=0;item&lt;window.frames.length;item++)
{
window.frames[item].document.open();
var extension=images[item].substr(-4).toLowerCase();
// alert(extension);
head="&lt;html&gt;&lt;head&gt;&lt;/head&gt;&lt;body&gt;";
tail="&lt;/body&gt;&lt;/html&gt;";
if(extension==".jpg"||extension=="jpeg"||extension=="gif")
{
window.frames[item].document.write(head+"&lt;img height=100% width=100% src="+images[item]+"&gt;"+tail);
}
else
{
window.frames[item].document.write(head+"&lt;embed height=100% width=100% src="+images[item]+"&gt;"+tail);
}
window.frames[item].document.close();
}
item=0;
next();
document.body.style.cursor = 'none';
}
catch(err){alert("bad");}
}
&lt;/script&gt;
&lt;/head&gt;
&lt;body onload="init()"&gt;
&lt;div class="nocursor"&gt;
&lt;iframe id="0" height=0 width=0 frameborder=0 marginheight=0 marginwidth=0 scrolling=no&gt;&lt;/iframe&gt;
&lt;/div&gt;
&lt;div class="nocursor"&gt;
&lt;iframe id="1" height=0 width=0 frameborder=0 marginheight=0 marginwidth=0 scrolling=no&gt;&lt;/iframe&gt;
&lt;/div&gt;
&lt;div class="nocursor"&gt;
&lt;iframe id="2" height=0 width=0 frameborder=0 marginheight=0 marginwidth=0 scrolling=no&gt;&lt;/iframe&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;
Copy linkTweet thisAlerts:
@pixxeldigitalJul 26.2012 — Hi,

this is a nice code i will also try this code.
×

Success!

Help @jeffsadowski spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.19,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...