javascript - how to show the content of other websites in my website - Stack Overflow

admin2025-04-20  0

I am looking for a code which does a simple task. below is the task

let's say my site is

I want when my user go to this site they see a box on top of the page which shows my site name and also my contact details and also a countdown timer.

below this line I want to show the exact same website of few different URL and I want to set a timer as well so that these few websites rotate and that timer on top shows how long it is until the next refresh and next website. I want only this part of the webpage to refresh and I want the top line to be still.

.jpg

you can see what I want in the image above.

I was told that it can be done using iframe but I don't know how to do it and I also don't want scroll

I appreciate if you could help me

I found this solution and it seems to be working. I just need the countdown timer and also I want to crop out let's say 200px of top of each website and like shift it up because one page doesn't show all the content I want unless using scrolling and I don't want that.

    <!DOCTYPE html>
    <html>
    <body>

    <div align="center" style="border:4px solid red ">
    <div style="color:#0000FF">
    <h3>some content<color:#0000FF/h3>
<h3>some more content<color:#0000FF/h3>
</div> 
</div>

<iframe id="rotator" src="" width="100%" height="600" scrolling="no" border="0" ></iframe>

<script>
// start when the page is loaded
window.onload = function() {

var urls = [
"",
"",
"", 
"",
"",
];

  var index = 1;
  var el = document.getElementById("rotator");

  setTimeout(function rotate() {

    if ( index === urls.length ) {
  index = 0;
}

el.src = urls[index];
index  = index + 1;

// continue rotating iframes
setTimeout(rotate, 5000);

}, 5000); // 5000ms = 5s
 };
</script>

</body>
</html> 

I am looking for a code which does a simple task. below is the task

let's say my site is http://www.url.

I want when my user go to this site they see a box on top of the page which shows my site name and also my contact details and also a countdown timer.

below this line I want to show the exact same website of few different URL and I want to set a timer as well so that these few websites rotate and that timer on top shows how long it is until the next refresh and next website. I want only this part of the webpage to refresh and I want the top line to be still.

http://i58.tinypic./s6t84h.jpg

you can see what I want in the image above.

I was told that it can be done using iframe but I don't know how to do it and I also don't want scroll

I appreciate if you could help me

I found this solution and it seems to be working. I just need the countdown timer and also I want to crop out let's say 200px of top of each website and like shift it up because one page doesn't show all the content I want unless using scrolling and I don't want that.

    <!DOCTYPE html>
    <html>
    <body>

    <div align="center" style="border:4px solid red ">
    <div style="color:#0000FF">
    <h3>some content<color:#0000FF/h3>
<h3>some more content<color:#0000FF/h3>
</div> 
</div>

<iframe id="rotator" src="http://www.zcast.ir" width="100%" height="600" scrolling="no" border="0" ></iframe>

<script>
// start when the page is loaded
window.onload = function() {

var urls = [
"http://www.zcast.ir",
"http://www.tgju",
"http://www.on3.ir", 
"http://www.goldinfo.ir",
"http://www.zarban.ir",
];

  var index = 1;
  var el = document.getElementById("rotator");

  setTimeout(function rotate() {

    if ( index === urls.length ) {
  index = 0;
}

el.src = urls[index];
index  = index + 1;

// continue rotating iframes
setTimeout(rotate, 5000);

}, 5000); // 5000ms = 5s
 };
</script>

</body>
</html> 
Share Improve this question edited Apr 16, 2014 at 10:24 user3540090 asked Apr 16, 2014 at 7:47 user3540090user3540090 211 gold badge1 silver badge3 bronze badges 3
  • use seamless attribute to hide borders and scrollbars in iframe – Amit Soni Commented Apr 16, 2014 at 7:52
  • You can use iframe but it can be denied by target site. See my answer and demo for further details stackoverflow./questions/23103134/… – Hüseyin BABAL Commented Apr 16, 2014 at 8:09
  • I updated my question. could you please answer it now – user3540090 Commented Apr 16, 2014 at 10:25
Add a ment  | 

2 Answers 2

Reset to default 1

Yes absolutely you can do that using iframe

1) set iFrame scrolling attribute to no:

<iframe src="/default.asp" width="200" height="200" scrolling="no">
</iframe>

read more: iFrame attr (w3Schools)

2) setTimeout for the timer: - see more
3) Reload the iframe from parent window - see more

You can use style position:fixed; and top:0; to place the div on top of your page:

<div style="position:fixed;top:0;"> some content here </div>

so thats it! :)

You can use iframe but, be sure that target website may disallow iframe embed. You can use following code;

var websites = new Array(
    "http://www.hurriyet.",
    "http://www.milliyet.",
    "http://www.amazon."
);
var counter = 0;
var sTimeOut = setInterval(function () {
    var index = counter%(websites.length);

    $("#website_div").html($('<iframe src="' + websites[index] + '" width="500" height="500" border="0" scrolling="no"/>' ));
    counter++;  
}, 5000);

Put your websites in list, and it will rotated.

Here is a working demo: Demo

转载请注明原文地址:http://conceptsofalgorithm.com/Algorithm/1745105936a285290.html

最新回复(0)