/    Sign up×
Community /Pin to ProfileBookmark

Load a website in a table on another site

I have a website now and on one of the pages I need to have a table, that loads another website inside of it. I have tried the code below with no luck. The website is not loading up in the table, I also need for it to refresh the website link “url” every 5 minutes.

This is the code I am trying now:

<!DOCTYPE html>
<html>
<head>
<title>Reload iframe demo</title>
<script type=”text/javascript”>
var reloadInterval;
var url=’http://www.cnn.com‘;
var reload_time_in_seconds=5000;

function reloadFrame(id){
document.getElementById(id).src=url;
console.log(“interval triggered”);
}
function initiateInterval(id){
document.getElementById(id).src=url;
reloadInterval=setInterval(“reloadFrame(“+id+”)”,reload_time_in_seconds*5000);
}

</script>
</head>
<body id=”body” onload=”initiateInterval(‘myframe’)”>
<iframe height=”600″ width=”100%” id=”myframe” ></iframe>
</body>
</html>

to post a comment
JavaScript

5 Comments(s)

Copy linkTweet thisAlerts:
@SempervivumNov 12.2017 — You assing 5000 to your variable reload_time_in_seconds and later on you multiply this by 5000 when calling setInterval. Calculate the result!

Should read:

var reload_time_in_seconds=5;

and:

reloadInterval=setInterval("reloadFrame("+id+")",reload_time_in_seconds*1000);
Copy linkTweet thisAlerts:
@rootNov 12.2017 — When posting code, please remember to use forum BB Code tags to wrap around your code (see my signature for examples).
Copy linkTweet thisAlerts:
@robSandsauthorNov 13.2017 — Ok, I updated the code and now in the frame the webpage does not load I get a 404 error loading in the table. Ideas on how to fix this and get it to load the url website in the table and refresh as requested? Code is below:


[CODE]


<!DOCTYPE html>
<html>
<head>
<title>Reload</title>
<script type="text/javascript">
var reloadInterval;
var url='www.cnn.com';
var reload_time_in_seconds=5;

function reloadFrame(id){
document.getElementById(id).src=url;
console.log("interval triggered");
}
function initiateInterval(id){
document.getElementById(id).src=url;
reloadInterval=setInterval("reloadFrame("+id+")",reload_time_in_seconds*1000);
}

</script>
</head>
<body id="body" onload="initiateInterval('myframe')">
<iframe height="600" width="100%" id="myframe" ></iframe>
</body>
</html>
[/CODE]
Copy linkTweet thisAlerts:
@SempervivumNov 13.2017 — You need to specify the complete url including the protocol:

http://www.cnn.com

When I try to test this, the console says:
Refused to display 'http://edition.cnn.com/' in a frame because an ancestor violates the following Content Security Policy directive: "frame-ancestors 'self' *.cnn.com:* *.turner.com:* courageousstudio.com".[/QUOTE]I suspect, CNN does not like their content being displayed in an iframe.

However, CNN provides a news feed which can be displayed in an iframe:

http://rss.cnn.com/rss/edition.rss
×

Success!

Help @robSands spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.8,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...