0

Just want a variable parameter in an html url like this:

mywebpage.com/something.html?width=(Parameter1)&height=(Parameter2)

But in the content of that webpage i want to add this:

<script>fid="example"; width=(Parameter1); height=(Parameter2);</script>

How can i do it using only javascript and Html

FlyezTV
  • 13
  • 1
  • 4

2 Answers2

0

Here is code suggested from similar question (How to get the value from the GET parameters?)

var QueryString = function () {
  // This function is anonymous, is executed immediately and 
  // the return value is assigned to QueryString!
  var query_string = {};
  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 first entry with this name
    if (typeof query_string[pair[0]] === "undefined") {
      query_string[pair[0]] = pair[1];
        // If second entry with this name
    } else if (typeof query_string[pair[0]] === "string") {
      var arr = [ query_string[pair[0]], pair[1] ];
      query_string[pair[0]] = arr;
        // If third or later entry with this name
    } else {
      query_string[pair[0]].push(pair[1]);
    }
  } 
    return query_string;
} ();
Community
  • 1
  • 1
Johan
  • 8,068
  • 1
  • 33
  • 46
  • I want something like this http://www.redzer.tv/canal1.php?width=350&height=200 but in html, look at that url when you change the width value in the url, it changes the width of the videostream content, Is there a way to do that in HTML and javascript? – FlyezTV Jun 19 '13 at 19:29
-1

So long the list of variables is somewhat fixed and small in quantity, keep it simple.

HTML:

<a href="#" id="some-link-id>Click me!</a>

JS:

var width = 100;
var height = 100;

var link  = document.getElementById('some-link-id');
var url   = "http://mywebpage.com/page.html?width=" + width + "&height=" + height;
link.href = url;

Or to update the URL of the page you are on, simply set window.location.href

var width = 100;
var height = 100;

var url = "http://mywebpage.com/page.html?width=" + width + "&height=" + height;
window.location.href = url;
Alex Wayne
  • 178,991
  • 47
  • 309
  • 337
  • I want something like this http://www.redzer.tv/canal1.php?width=350&height=200 but in html, look at that url when you change the width value in the url, it changes the width of the videostream content, Is there a way to do that in HTML and javascript? – FlyezTV Jun 19 '13 at 19:27
  • Yes there is. It is my answer. That's why it has `HTML` and `JS` in it. So I don't understand your question... – Alex Wayne Jun 19 '13 at 19:37
  • But it doesnt work check out that webpage it contains a videostream, it can not change with your method – FlyezTV Jun 19 '13 at 19:48
  • You want to change the URL of the page you are on? Oh, that was totally not clear... See my edit. – Alex Wayne Jun 19 '13 at 19:51
  • Yes look how it changes, compare: http://www.redzer.tv/canal1.php?width=350&height=200 and http://www.redzer.tv/canal1.php?width=720&height=480 Thats made with php but i wanna do that with html and javascript – FlyezTV Jun 19 '13 at 20:33
  • I cannot figure out what you want here. You will need to be much more specific. – Alex Wayne Jun 19 '13 at 21:42
  • look http://www.pirlotves.com/canal-1.php there says "copy this code into your website so you can get the video in the size you want" that code includes an iframe to a php webpage where the video is stored, i want to do that but in html and javascript, if you help me i can offer you some money – FlyezTV Jun 19 '13 at 22:07