对于无法在框架中加载的网页,每隔几秒钟显示一次网页?

时间:2022-10-28 01:24:23

I want to create a web page to display amazon products (kiosk-like display) and the goal is to change to the next product every few seconds. Amazon pages can't load in frames, so using php (or any client side/server side solution) is there a way to set a timer to change to the next product?
Here is the sequence:

我想创建一个显示亚马逊产品的网页(类似于自助服务终端的显示器),目标是每隔几秒钟更换一次下一个产品。亚马逊页面无法加载帧,因此使用php(或任何客户端/服务器端解决方案)是否有办法设置计时器以更改为下一个产品?这是序列:

Show product 1 -----> show product 2 ----> show product 3 ----> repeat

显示产品1 ----->显示产品2 ---->显示产品3 ---->重复

Here is a simple code that uses frames but it doesn't load amazon in the frame. My next step was to add timer but first I need to figure out how I can show amazon pages in a fashion that I can move to the next one after a few seconds. Basically the issue is that without the frames how can I set a timer (either server side or client side) to redirect the page to the next product?

这是一个使用框架的简单代码,但它不会在框架中加载亚马逊。我的下一步是添加计时器,但首先我需要弄清楚如何以一种方式显示亚马逊页面,我可以在几秒钟后移动到下一页。基本上问题是如果没有框架,我如何设置计时器(服务器端或客户端)将页面重定向到下一个产品?

<!DOCTYPE html>
<html>
<body>
<iframe width="500" height="400" id="myFrame" src="http://www.amazon.com"></iframe>

<p>Click the button to change the value of the src attribute in the iframe.</p>

<button onclick="myFunction()">Try it</button>

<script>
function myFunction() {
    document.getElementById("myFrame").src = "http://www.amazon.com";
}
</script>

</body>
</html>

1 个解决方案

#1


0  

Coding method (javascript and popup window):

编码方法(javascript和弹出窗口):

I was able to do this with a pop up window instead of frames. Basically what you need to do is to open a pop up and control the url of that pop up through the parent page. Here is a sample code of the solution:

我能够通过弹出窗口而不是框架来完成此操作。基本上你需要做的是打开一个弹出窗口并通过父页面控制弹出的URL。以下是解决方案的示例代码:

<!DOCTYPE html>
<html>
<head>
</head>
<body>
<script type='text/javascript'>   
window.setInterval(function(){
  process();
}, 15000);

arr = ['http://www.amazon.com/Apple-AirPort-Express-Station-MC414LL/dp/B008ALA2RC', 
       'http://www.amazon.com/dp/B0087NZ31S'
      ];

var popup = window.open('http://www.amazon.com','rotator');

i = 0;
function process(){
      i++;
      index =i%arr.length;
      popup.location.href=arr[index];
}   
</script>

</body>
</html>

Browser extension method:

浏览器扩展方法:

I found a chrome extension named Rotisserie URL Rotator that does the rotation, can set a time for each page in seconds. Basically you will specify a set of (url, time) tuples and it will rotate on those urls for the specified times. I also found a few more but for now this does job for the display purpose well. I also found one that will rotate between tabs and had a lot more features like specifying random times, etc. But my main purpose was to show the page in only one tab.

我找到了一个名为Rotisserie URL Rotator的镀铬扩展程序来执行旋转,可以在几秒钟内为每个页面设置时间。基本上,您将指定一组(url,time)元组,它将在指定时间内在这些URL上旋转。我还发现了一些,但是现在这对显示目的很有帮助。我还发现了一个将在选项卡之间旋转并具有更多功能,如指定随机时间等。但我的主要目的是仅在一个选项卡中显示该页面。

#1


0  

Coding method (javascript and popup window):

编码方法(javascript和弹出窗口):

I was able to do this with a pop up window instead of frames. Basically what you need to do is to open a pop up and control the url of that pop up through the parent page. Here is a sample code of the solution:

我能够通过弹出窗口而不是框架来完成此操作。基本上你需要做的是打开一个弹出窗口并通过父页面控制弹出的URL。以下是解决方案的示例代码:

<!DOCTYPE html>
<html>
<head>
</head>
<body>
<script type='text/javascript'>   
window.setInterval(function(){
  process();
}, 15000);

arr = ['http://www.amazon.com/Apple-AirPort-Express-Station-MC414LL/dp/B008ALA2RC', 
       'http://www.amazon.com/dp/B0087NZ31S'
      ];

var popup = window.open('http://www.amazon.com','rotator');

i = 0;
function process(){
      i++;
      index =i%arr.length;
      popup.location.href=arr[index];
}   
</script>

</body>
</html>

Browser extension method:

浏览器扩展方法:

I found a chrome extension named Rotisserie URL Rotator that does the rotation, can set a time for each page in seconds. Basically you will specify a set of (url, time) tuples and it will rotate on those urls for the specified times. I also found a few more but for now this does job for the display purpose well. I also found one that will rotate between tabs and had a lot more features like specifying random times, etc. But my main purpose was to show the page in only one tab.

我找到了一个名为Rotisserie URL Rotator的镀铬扩展程序来执行旋转,可以在几秒钟内为每个页面设置时间。基本上,您将指定一组(url,time)元组,它将在指定时间内在这些URL上旋转。我还发现了一些,但是现在这对显示目的很有帮助。我还发现了一个将在选项卡之间旋转并具有更多功能,如指定随机时间等。但我的主要目的是仅在一个选项卡中显示该页面。