每天设置合适的电台 [英] Set the right radio station per day
问题描述
大家好b
$ b我非常业余,并且正在尝试使用html完成项目 一位朋友和wix。
我们希望每天都能播出合适的广播电台。
基于 UTC +1时间我们想要
m https: // www.iradeo.com/station/140679 salsa
t https: // www.iradeo.com/station/140678 rumba
w https: // www.iradeo.com/station/140711 tango
t https: // www.iradeo.com/station/140712国家/地区
f https: // www.iradeo.com/station/140713 house
s https: // www.iradeo。 com / station / 140714休息室
s https: // www.iradeo.com/station/ 140715 classic
我知道如何将放在的中心第一页广播电台通过
< iframe width = 100% height = 55 src = https://www.iradeo.com/station/embed/140714?override_schedule_colors=1 frameborder = 0 scrolling = no > < / iframe < span class =code-keyword>> < iframe width = 100% height = 55 src = https://www.iradeo.com/station/embed/140714?override_schedule=1 frameborder = 0 scrolling = no > < / iframe >
我' 知道如何根据时间和日期使这个站点交替。也许结合if语句?谢谢!
rosemary.stevens88@gmail.com
我尝试过:
我最好的? :p
< iframe width =100%height =55src =https://www.iradeo.com/station/embed/140714 ?override_schedule_colors = 1frameborder =0scrolling =no>< / iframe>< iframe width =100%height =55src =https://www.iradeo.com/station / embed / 140714?override_schedule = 1frameborder =0scrolling =no>< / iframe>
在JavaScript中,您可以获得当天,看看哪个站。例如像这样,
var date = new 日期();
var day = date.getDay(); // 3
这是一个漂亮的这样做很困惑,所以你可以创建一个帮助函数来以友好的方式获取名称。像这样,
function getNameOfDay(day){
开关(天){
案例 1 : return ' Monday';
case 2 : return ' Tuesday';
// ......等等。
}
}
然后,您可以使用此功能选择要播放的电台。
var dayName = getNameOfDay( new 日期( ).getDay()); // 获取名称
如果(dayName == ' Monday'){
var myIframe = document .getElementById( setIdtoIframe跨度>);
myIframe.src = monday-station;
} 其他 如果 {} // 向前移动。
这样,你就可以解决这个问题并执行检查开始申请。每次用户登录时都运行脚本。
首先删除src
属性,并给出< iframe>
id
:
< iframe id = radio width = 100% height = 55 frameborder = 0 滚动 <跨度cl ass =code-keyword> = no > < / iframe >
然后,在页面加载时添加一些Javascript来初始化< iframe>
:
window .onload = function (){
// 0 =星期日,1 =星期一,...
var stations = [
https://www.iradeo.com/station/140715 ,
https://www.iradeo.com/station/140679,
https://www.iradeo.com/station/140678,
https://www.iradeo.com/station/140711,
https://www.iradeo.com/station/140712,
https://www.iradeo.com/station/140713,
https://www.iradeo.com/station/140714
];
var today = new 日期跨度>();
var day = today.getDay();
var station = stations [day];
document .getElementById( radio).setAttribute( src,station);
};
示例 [ ^ ]
站点
数组必须以星期日开始,因为这就是Javascript日期数字的表示方式:
Date.prototype.getDay() - JavaScript | MDN [ ^ ]
Hi guys
I am pretty amateur and trying to finish a project for a friend with html and wix.
We want the right radio station to appear per day.
Based in UTC +1 time we want
m https://www.iradeo.com/station/140679 salsa
t https://www.iradeo.com/station/140678 rumba
w https://www.iradeo.com/station/140711 tango
t https://www.iradeo.com/station/140712 country
f https://www.iradeo.com/station/140713 house
s https://www.iradeo.com/station/140714 lounge
s https://www.iradeo.com/station/140715 classic
I know how to put in the center of a page one radio station loading via
<iframe width="100%" height="55" src="https://www.iradeo.com/station/embed/140714?override_schedule_colors=1" frameborder="0" scrolling="no"></iframe><iframe width="100%" height="55" src="https://www.iradeo.com/station/embed/140714?override_schedule=1" frameborder="0" scrolling="no"></iframe>
I don't know how to make this alternate the stations based on time and day. Perhaps with a combination of if statements? Thank you!
rosemary.stevens88@gmail.com
What I have tried:
my best? :p
<iframe width="100%" height="55" src="https://www.iradeo.com/station/embed/140714?override_schedule_colors=1" frameborder="0" scrolling="no"></iframe><iframe width="100%" height="55" src="https://www.iradeo.com/station/embed/140714?override_schedule=1" frameborder="0" scrolling="no"></iframe>
In JavaScript, you can get the current day and see which station to play. For example like this,
var date = new Date(); var day = date.getDay(); // 3
It is a pretty much confused way of doing this, so you can create a helper function to get the name in a friendly way. Like this,
function getNameOfDay(day) { switch(day) { case 1: return 'Monday'; case 2: return 'Tuesday'; // ... So on. } }
Then, you can use this function to select which radio station to play.
var dayName = getNameOfDay(new Date().getDay()); // Get the name, if(dayName == 'Monday') { var myIframe = document.getElementById("setIdtoIframe"); myIframe.src = "monday-station"; } else if {} // Move onwards.
This way, you can get around this problem and perform the check on the start of your application. Run the script, each time the user logs in.
Start by removing thesrc
attribute, and giving the<iframe>
anid
:
<iframe id="radio" width="100%" height="55" frameborder="0" scrolling="no"></iframe>
Then, add some Javascript to initialize the<iframe>
when the page loads:
window.onload = function(){ // 0 = Sunday, 1 = Monday, ... var stations = [ "https://www.iradeo.com/station/140715", "https://www.iradeo.com/station/140679", "https://www.iradeo.com/station/140678", "https://www.iradeo.com/station/140711", "https://www.iradeo.com/station/140712", "https://www.iradeo.com/station/140713", "https://www.iradeo.com/station/140714" ]; var today = new Date(); var day = today.getDay(); var station = stations[day]; document.getElementById("radio").setAttribute("src", station); };
Example[^]
Thestations
array has to start with Sunday, since that's how Javascript day numbers are represented:
Date.prototype.getDay() - JavaScript | MDN[^]
这篇关于每天设置合适的电台的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!