Search code examples
javascriptblogsbloggerblogspot

Blogger IFRAME reciveing URL_argument from URL


Is it possible to have a page (or post) in the BLOGGER platform that works similar to this:

blog.blogspot.com/a.html?url=http://google.com/

And it would embed in an IFRAME the argument (http://google.com/)

I already have the code for the IFRAME, but it's static:

<iframe src ="http://google.com/" width="100%" height="300">
<p>Your browser does not support iframes.</p>
</iframe>

Ps.: My real objective is to get 2 arguments (one for the URL and another for the return page), but If someone helps me with 1 argument, I think I can adapt it for several arguments.

Thnx in advance


Solution

  • Done. I tested it in bloger and it does work.

    <script>
    
    function getQueryVariable(variable) { 
      var query = window.location.search.substring(1); 
      var vars = query.split("&"); 
      for (var i=0;i<vars.length;i++) { 
        var pair = vars[i].split("="); 
        if (pair[0] == variable) { 
          return pair[1]; 
        } 
      } 
    } 
    </script>
    
    <script>
    document.write('<iframe src ="'+ getQueryVariable("url") + '" width="100%" height="300"><p>Your browser does not support iframes.</p></iframe>')
    </script>
    

    Hope this helps