Jump to content

Changing images ....


eduard
 Share

Recommended Posts

To changes the images of my website (www.eduardlid.net) after a certain time, I can use the setInterval () method of JavaScript? If so, where do I find how to do this (images)?

Link to comment
Share on other sites

something like this

// imgId is the id of the image you want to change// newSrc is the new image pathfunction swapImg(imgId,newSrc){elm = document.getElementById(imgId);elm.src = newSrc;return true;}//pre load the imagevar img5=new Image();img5.src="myImage.jpg";// mouse over example<img src="someImage.jpg" onmouseover="swapImg(this.id,img5.src);" />

Link to comment
Share on other sites

something like this
// imgId is the id of the image you want to change// newSrc is the new image pathfunction swapImg(imgId,newSrc){elm = document.getElementById(imgId);elm.src = newSrc;return true;}//pre load the imagevar img5=new Image();img5.src="myImage.jpg"; // mouse over example<img src="someImage.jpg" onmouseover="swapImg(this.id,img5.src);" />

Ok, thanks!
Link to comment
Share on other sites

I don't don't know what that means. I'm not sure what the inclusion of CSS has to do with JS inclusion. If you look at the tutorials they tell you the way you can add JS to your page. Like CSS though, it is recommended that you include it through an external file.

Link to comment
Share on other sites

I don't don't know what that means. I'm not sure what the inclusion of CSS has to do with JS inclusion. If you look at the tutorials they tell you the way you can add JS to your page. Like CSS though, it is recommended that you include it through an external file.
Ok, but when I want the JS function in the head I´ve to write: : <script type="text/javascript"> aswell as : <script type="text/css">? Sorry, I was confused: css is a style; not a script! Edited by eduardlid
Link to comment
Share on other sites

Sorry, I was confused: css is a style; not a script
Yes... but you said
What about my css if I write: <script type="text/javascript">?
And that is what thescientist is correction you about. Seeing that you caught your own error, I'm guessing this was just a typo, correct?
Link to comment
Share on other sites

something like this
// imgId is the id of the image you want to change// newSrc is the new image pathfunction swapImg(imgId,newSrc){elm = document.getElementById(imgId);elm.src = newSrc;return true;}//pre load the imagevar img5=new Image();img5.src="myImage.jpg"; // mouse over example<img src="someImage.jpg" onmouseover="swapImg(this.id,img5.src);" />

I´m beginning to understand your reply (I´m now learning JS), but how do I write it in my html file?
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
 Share

×
×
  • Create New...