₦airaland Forum

Welcome, Guest: RegisterLoginWith GoogleTrendingRecentNew

Stats: 3,325,457 members, 8,422,159 topics. Date: Sunday, 07 June 2026 at 07:11 PM

Toggle theme

Please I Need Help Writing This Code - Programming - Nairaland

Nairaland ForumScience/TechnologyProgrammingPlease I Need Help Writing This Code (821 Views)

1 Reply

Please I Need Help Writing This Code by StevensJojo(op): 2:46pm On May 29, 2015
Hi guys,

I'm a digital marketer with a little knowledge of html and css.

Today I hit a brick wall. Iv got a task I need to execute but it's JavaScript- I'm clueless!

Here's the instructions I'm supposed to follow-

1. Code a JAvaScript

2. Put 3 blogpost urls in the JavaScript

3. Create a function that would open all the Web addresses in my browser

4. Make the function sleep for 3-4 minutes

5. When the JavaScript reaches the end, it'll automatically bounce and repeat.

Please help?!
Re: Please I Need Help Writing This Code by kudaisi(m): 4:37pm On May 29, 2015
Not necessarily the best method to go about it, but this should work.
<!DOCTYPE html>
<html>
<head>
<script>

var urls = [
"http://www.yahoo.com/",
"http://www.outlook.com/",
"http://www.gmail.com/"
];
console.log("test"wink;
var length = urls.length;
var i = 0
function getUrl(){
if(i==length - 1 ){i=0;}
return urls[i];
}

function openUrl(url){
console.log("Opening url: "+url);
//window.open(url, "_self"wink//curent page
//window.open(url, "_parent"wink;// parent fame
window.open(url, "_blank"wink//new window (default)
//window.open(getUrl(), "_top"wink;// replaces frameset
i++;
}

function sleep() {
setTimeout(function () {
openUrl(getUrl());
sleep();
}, 10000);
}

sleep();
</script>
</head>
<body>
</body>
</html>
Re: Please I Need Help Writing This Code by StevensJojo(op): 5:11pm On May 29, 2015
Thanks!
kudaisi:
Not necessarily the best method to go about it, but this should work.
<!DOCTYPE html>
<html>
<head>
<script>

var urls = [
"http://www.yahoo.com/",
"http://www.outlook.com/",
"http://www.gmail.com/"
];
console.log("test"wink;
var length = urls.length;
var i = 0
function getUrl(){
if(i==length - 1 ){i=0;}
return urls[i];
}

function openUrl(url){
console.log("Opening url: "+url);
//window.open(url, "_self"wink//curent page
//window.open(url, "_parent"wink;// parent fame
window.open(url, "_blank"wink//new window (default)
//window.open(getUrl(), "_top"wink;// replaces frameset
i++;
}

function sleep() {
setTimeout(function () {
openUrl(getUrl());
sleep();
}, 10000);
}

sleep();
</script>
</head>
<body>
</body>
</html>
1 Reply

Help On This CodeA Test For Python Guys. What Will This Code Do?Explain This Code And Get Commended234

SSH Keys Generated On Debian VulnerableInquiry About Programming/software Development Training And Trendnet ScholarshipWhat Is The Best Web Design Software And How Can I Learn It?