html - Use JavaScript variable as iframe src? -


i'm trying use javascript variable src in <iframe>, user able load other content choosing scr in menu, changes variable. default src url apps/start.php.

here code index.php:

    <script>         var appurl = "start.php";         document.getelementbyid("app").src = "apps/" + appurl();     </script>      <iframe id="app" src="">      </iframe> 

the problem can't first small part working... <script> tag in <head>. , when src changing new document automatically load?

wait page load (note going work when iframe on domain)

window.onload = function(){  var appurl = "start.php";  document.getelementbyid("app").src = "apps/" + appurl; }; 

Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -