Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If I have understood you, you need to change the visibility of some div elements in all of the browsers, that have your site opened, right? The way, that you've selected is very strange for that, you can use jQuery's ajax and setInterval for this. For example:</p> <p>PHP for users:</p> <pre><code>&lt;?php $curSlide = file_get_contents("/tmp/slidenumber.txt");//Get current active slide if (!isset($_POST['testSlideChange'])): //If there are no POST var, saying that this is an ajax update request, output the HTML page to browser: ?&gt; &lt;div id="slide-1" class="slide &lt;?php if($curSlide==1) echo 'visible'?&gt;"&gt;Content of slide1&lt;/div&gt; &lt;div id="slide-2" class="slide &lt;?php if($curSlide==2) echo 'visible'?&gt;"&gt;Content of slide2&lt;/div&gt; &lt;div id="slide-3" class="slide &lt;?php if($curSlide==3) echo 'visible'?&gt;"&gt;Content of slide3&lt;/div&gt; &lt;div id="slide-4" class="slide &lt;?php if($curSlide==4) echo 'visible'?&gt;"&gt;Content of slide4&lt;/div&gt; &lt;?php else: //else, if we have POST-var, just return current slide as a number echo $curSlide; endif; ?&gt; </code></pre> <p>CSS:</p> <pre><code>slide { display:none; } slide.visible { display:block; } </code></pre> <p>JS:</p> <pre><code>$(document).ready(function(){ //test for slide change every 1 second setInterval(testSlideChange,1000); }); function testSlideChange() { //make post ajax request $.post('http://my.web.site.com/this_page.php', {'testSlideChange' : 1} , function(data) { //if result slide hasn't got class "visible", lets take it from the visible one, and give to a new one. if (!$('#slide-' + data).hasClass('visible') { $('.slide.visible').removeClass('visible'); $('#slide-' + data).addClass('visible'); } } } </code></pre> <p>To change slide at server side you have just write another number to a file /tmp/slidenumber.txt, it could be done by simple server php script or manually.</p> <hr> <p>I've created an example of how it should work. Working example!</p> <p>User page: <a href="http://kovka54.ru/test/index.php" rel="nofollow">http://kovka54.ru/test/index.php</a> (user can see slides here)<br> Admin page: <a href="http://kovka54.ru/test/admin.php" rel="nofollow">http://kovka54.ru/test/admin.php</a> (admin can set active slide here)<br> Open this pages on a separate windows (for example, in two browsers) and watch, how user's slide is changed when you change slide in admin side.<br> The example consists of 3 files: index.php ,admin.php and slidenumber.txt (which contains just single number, at the begining it's "1" (without quotes). content of index.php: <a href="http://pastebin.com/zge3MbAQ" rel="nofollow">http://pastebin.com/zge3MbAQ</a>, content if admin.php: <a href="http://pastebin.com/J5eDEbSe" rel="nofollow">http://pastebin.com/J5eDEbSe</a><br></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload