Java script problem

User 126415 Photo


Registered User
36 posts

Hi -
I want to use the following flash mark-up in VSD.

The mark up and demo are at http://jsfiddle.net/arunpjohny/Eccwt/.

I have entered the code in HTML Editor (copied below) and the script doesn’t run.

<!DOCTYPE html>
<HTML lang="en">
<HEAD>
<META charset="utf-8">
<META name="generator"
content="CoffeeCup HTML Editor (www.coffeecup.com)">
<META name="dcterms.created"
content="Sun, 14 Dec 2014 18:45:28 GMT">
<META name="description"
content="">
<META name="keywords"
content="">
<TITLE>hp test</TITLE>

<STYLE type="text/css">
#fds li {
display:none;}
</STYLE>

<!--[if IE]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
<SCRIPT>
function animate() {
function fadeTo(lis, duration, opacity, callback) {
if (!lis.length) {
callback();
}
var $lis = $(lis.shift());
$lis.delay(1000).fadeTo(duration, opacity, function () {
fadeTo(lis, duration, opacity, callback);
})
}
fadeTo($('#fds li').get(), 500, 1, function () {
setTimeout(function () {
fadeTo($('#fds li').get(), 500, 0, function () {
setTimeout(animate, 5000);
})
}, 5000);
})

}
animate();
</SCRIPT>

</HEAD>

<BODY>
<div> <UL id="fds">
<LI>One</LI>
<LI>Two</LI>
<LI>Three</LI>
<LI>Four</LI>
</UL></div>

</BODY>
</HTML>

I can’t imagine what I am missing.

Any guidance will be greatly appreciated.

Robert
User 2484360 Photo


Registered User
3,293 posts

Are you uploading this and testing it once uploaded or are you trying to preview this?

If preview, upload and let us know if it is working. :)
User 126415 Photo


Registered User
36 posts

Both -

preview (HTML Editor and VSD)
and uploaded to my test site: http://nierikasol2.coffeecup.com/Page4.html
User 2484360 Photo


Registered User
3,293 posts

That is because there was an error.

[Error] ReferenceError: Can't find variable: $
animate (Page4.html, line 100)
global code (Page4.html, line 120)

Try pasting the javascript in once again.
User 126415 Photo


Registered User
36 posts

Thanks for such a speedy reply!

Pasted again and no improvement.
User 271657 Photo


Ambassador
3,816 posts

Sol, have you installed and/or linked to the JQuery library?
https://code.jquery.com/ui/
I love deadlines. I like the whooshing sound they make as they fly by. (Douglas Adams)
https://www.callendales.com
User 126415 Photo


Registered User
36 posts

Nope.

What should I do now and (if you are so inclined) why should I do it?

Thanks alot!
User 271657 Photo


Ambassador
3,816 posts

If this is a JQuery code snippet, you'll need to link to the JQuery library so the script will be able to run.
At the top-left of your JS Fiddle, I see JQ version 1.9.1 listed.
To use that, you would put:
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="js/jquery-1.9.1.min.js"><\/script>')</script>

in your code (using VSD's Edit Head option)
You can see the JS code it links to here: https://code.jquery.com/ui/1.9.1/jquery-ui.min.js

Anyway, that one link is all you need to run whatever JQuery snippets/plugins you might want to use. Update the version as needed (check the link from my last post to see version details).
I love deadlines. I like the whooshing sound they make as they fly by. (Douglas Adams)
https://www.callendales.com
User 126415 Photo


Registered User
36 posts

That did it!

Thank you so much.:D

How does one know when to update a JQ version?

Robert
User 271657 Photo


Ambassador
3,816 posts

Usually, plugins or snippets will note what version they need so you don't try to run something from a too-outdated version or one that's still a bit experimental. I think I've still got 1.10.+ on most of my sites.
1.11 and 2.+ are also available, here's a run-down on the different versions:
http://blog.jqueryui.com/category/releases/
I love deadlines. I like the whooshing sound they make as they fly by. (Douglas Adams)
https://www.callendales.com

Have something to add? We’d love to hear it!
You must have an account to participate. Please Sign In Here, then join the conversation.