Jump to content

Sliding Homepage Image


Recommended Posts

Trying this from past 3 days. I really hope someone will help me on this.

I want to Homepage Logo Image to slide and show multiple images. To start, I have written a simple code:

I have added the following JavaScript in the head section header.tpl to change image every 2.5 seconds:

[removed]
var image1=new Image();
var image2=new Image();
var image3=new Image();
image1.src="/modules/editorial/homepage_logo1.png";
image2.src="/modules/editorial/homepage_logo2.png";
image3.src="/modules/editorial/homepage_logo3.png";
//variable that will increment through the images
var step=1;
function slideit(){
//if browser does not support the image object, exit.
if (!document.images)
return;
document.images.slide.src=eval("image"+step+".src");
if (step<3)
step++;
else
step=1;
//call function "slideit()" every 2.5 seconds
setTimeout("slideit()",2500);
};
[removed]

Modified Body tag line to call the above [removed]

<body {if $page_name}id="{$page_name|escape:'htmlall':'UTF-8'}"{/if}>

Added Name tag for Homepage Image in editorial.tpl

{$this_path}homepage_logo1.png

Link to comment
Share on other sites

Message got truncated above.

With the above code, a standalone html page is working. But once I put the function in the Head section of JavaScript, the page goes blank.

I am certainly new to Preta and would like to know if there is a procedure to add JavaScript functions in tpl files.

Any advice would be really appreciated. Thank you!
Brian.

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...