Okay so this is kind of complicated – hope you can help.
I’ve got a slideshow that plays when my site loads – the first slide is a 10-second HTML5 video that my wife insists be on the site even though I’m not a fan. I don’t like it because if you click on a link that’s a new page in the same window, then hit the “back” button, he video plays again. It’s only 10 seconds, but i know it’s irritating to some people. Plus Google “fixed” Chrome so that it will no longer auto-play any video with sound (unless it's from YouTube)…but that’s another discussion.
Figured I’d use cookies and the API to have it check to see if the page had been visited that day and if so, to move on to slide 2, which is just an image.
I have the Javascript for cookies working (using cookies.js from GitHub – https://github.com/madmurphy/cookies.js) I can set and read the cookies and manipulate text and alerts/popups based on whether the cookie is set or not. And I am doing all of the setting/reading *inside* the “Custom Javascript” window of the slider. So I know it’s working from there.
It listens for the slider to load, then checks the cookie value. If the cookie exists, it’s supposed to go to slide 2 – which is the image. If the cookie value is “null” then it should play slide 1 and load the cookie so future checks send the slider to slide 2.
Here is the code:
// listen for when the slider initially loads
revapi20.bind(‘revolution.slide.onloaded’, function() { console.log(‘Slider Loaded’);
// check cookie
var visited = docCookies.getItem(“visited”);
if (visited == null) { // cookie is empty
console.log(‘value is null’);
revapi20.revshowslide(1);
//yes, I know that expire time is a year – It’s that way only for testing. I plan to reduce it to 30 minutes once it’s working
} else {
// cookie has content
revapi20.revshowslide(2);
console.log(‘value is affirmative’);
}
});
What I get is the console content based on the cookies. In other words, on first load, console reports “Slider Loaded” – the cookie is null of course so the console log will report “cookie is null” then “SETTING COOKIE” – and I can see in the developer console that the cookie doesn’t exist – and the first slide plays. Upon refresh, I see “Slider Loaded” then “value is affirmative” (which means the cookie is loaded) and then slide 1 plays. So it’s working through the script - the cookies are being set - but the API calls are failing.
I even went back and removed all the script down to this:
Funny thing about that is the slider disappears – you can’t see it – but you can *hear* the audio from the video…
None of the other API calls seem to have any effect at all. It won’t pause, or return any other info. I’ve tried it with Jquery enable and disabled – no change in behavior.
I understand I’m probably doing something wrong, but I’m not sure what it is.
Okay so this is kind of complicated – hope you can help.
I’ve got a slideshow that plays when my site loads – the first slide is a 10-second HTML5 video that my wife insists be on the site even though I’m not a fan. I don’t like it because if you click on a link that’s a new page in the same window, then hit the “back” button, he video plays again. It’s only 10 seconds, but i know it’s irritating to some people. Plus Google “fixed” Chrome so that it will no longer auto-play any video with sound (unless it's from YouTube)…but that’s another discussion.
Figured I’d use cookies and the API to have it check to see if the page had been visited that day and if so, to move on to slide 2, which is just an image.
I have the Javascript for cookies working (using cookies.js from GitHub – https://github.com/madmurphy/cookies.js) I can set and read the cookies and manipulate text and alerts/popups based on whether the cookie is set or not. And I am doing all of the setting/reading *inside* the “Custom Javascript” window of the slider. So I know it’s working from there.
It listens for the slider to load, then checks the cookie value. If the cookie exists, it’s supposed to go to slide 2 – which is the image. If the cookie value is “null” then it should play slide 1 and load the cookie so future checks send the slider to slide 2.
Here is the code:
// listen for when the slider initially loads revapi20.bind(‘revolution.slide.onloaded’, function() {
console.log(‘Slider Loaded’);
// check cookie
var visited = docCookies.getItem(“visited”);
if (visited == null) {
// cookie is empty
console.log(‘value is null’);
revapi20.revshowslide(1);
//report setting cookie
console.log(‘SETTING COOKIE’);
//set cookie
docCookies.setItem(“visited”, “affirmative”, 31536e3);
//yes, I know that expire time is a year – It’s that way only for testing. I plan to reduce it to 30 minutes once it’s working
} else {
// cookie has content
revapi20.revshowslide(2);
console.log(‘value is affirmative’); }
});
What I get is the console content based on the cookies. In other words, on first load, console reports “Slider Loaded” – the cookie is null of course so the console log will report “cookie is null” then “SETTING COOKIE” – and I can see in the developer console that the cookie doesn’t exist – and the first slide plays. Upon refresh, I see “Slider Loaded” then “value is affirmative” (which means the cookie is loaded) and then slide 1 plays. So it’s working through the script - the cookies are being set - but the API calls are failing.
I even went back and removed all the script down to this:
revapi20.bind(‘revolution.slide.onloaded’, function() { console.log(‘Slider Loaded’); revapi20.revpause(); });
Nothing happens. The first slide plays, the second slide plays, then it stops.
I tired this:
revapi20.bind(‘revolution.slide.onloaded’, function() { console.log(‘Slider Loaded’); revapi20.revkill(); });
Funny thing about that is the slider disappears – you can’t see it – but you can *hear* the audio from the video…
None of the other API calls seem to have any effect at all. It won’t pause, or return any other info. I’ve tried it with Jquery enable and disabled – no change in behavior.
I understand I’m probably doing something wrong, but I’m not sure what it is.
Any assistance appreciated.
Thanks!
Tim
It's all good.
The company is moving their website to another platform so I get to write a whole new site under a whole new management system.
Lucky me, LOL