Note that there are some explanatory texts on larger screens.

plurals
  1. PORefresh page title every 10 seconds - Javascript
    text
    copied!<p>I am currently trying to refresh my page title every 10 seconds to ensure that the song info changes here:</p> <p><img src="https://i.stack.imgur.com/Efx5r.png" alt="enter image description here"></p> <p>But after the song changes, I am left with the same page title:</p> <p><img src="https://i.stack.imgur.com/qTuJt.png" alt="enter image description here"></p> <p>My JavaScript setInterval function isn't working correctly.</p> <p>Here's my code (what should have worked):</p> <pre><code>&lt;script type="text/javascript"&gt; function songToTitle() { document.title = "BDR | &lt;?php echo $radio_info['now_playing']; ?&gt;"; } songToTitle(); setInterval(songToTitle, 10000); &lt;/script&gt; &lt;title&gt;BDR | Loading Song Title...&lt;/title&gt; </code></pre> <p>I don't really know what's up here.</p> <p>It imports the song name correctly, but does not refresh.</p> <p>Can anyone help me with this?</p> <p><strong>EDIT:</strong></p> <p>I tried using this too:</p> <pre><code>&lt;script type="text/javascript"&gt; function songTitle(){ var xmlhttp; if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp=new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function() { if (xmlhttp.readyState==4 &amp;&amp; xmlhttp.status==200) { document.title.innerHTML = xmlhttp.responseText; } } xmlhttp.open("GET","http://www.x86cam.com/wp-content/plugins/songTitle.php",true); xmlhttp.send(); } songTitle(); setInterval(songTitle, 5000); &lt;/script&gt; </code></pre> <p>It won't even load the title.</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