Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var myArray = new Object();
- myArray["firstname"] = "Bob";
- myArray["lastname"] = "Smith";
- myArray["age"] = 25;
- delete myArray["lastname"];
- alert(myObj["SomeProperty"]);
- alert(myObj.SomeProperty);
- delete myObj["SomeProperty"];
- delete myObj.SomeProperty;
- Array.prototype.contains = function(obj)
- {
- var i = this.length;
- while (i--)
- {
- if (this[i] === obj)
- {
- return true;
- }
- }
- return false;
- }
- Array.prototype.add = function(key, value)
- {
- if(this.contains(key))
- this[key] = value;
- else
- {
- this.push(key);
- this[key] = value;
- }
- }
- Array.prototype.remove = function(key)
- {
- for(var i = 0; i < this.length; ++i)
- {
- if(this[i] == key)
- {
- this.splice(i, 1);
- return;
- }
- }
- }
- // Read a page's GET URL variables and return them as an associative array.
- function getUrlVars()
- {
- var vars = [], hash;
- var hashes = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&');
- for(var i = 0; i < hashes.length; i++)
- {
- hash = hashes[i].split('=');
- vars.push(hash[0]);
- vars[hash[0]] = hash[1];
- }
- return vars;
- }
- function ForwardAndHideVariables() {
- var dictParameters = getUrlVars();
- dictParameters.add("mno", "pqr");
- dictParameters.add("mno", "stfu");
- dictParameters.remove("mno");
- for(var i = 0; i < dictParameters.length; i++)
- {
- var key = dictParameters[i];
- var value = dictParameters[key];
- alert(key + "=" + value);
- }
- // And now forward with HTTP-POST
- aa_post_to_url("Default.aspx", dictParameters);
- }
- function aa_post_to_url(path, params, method) {
- method = method || "post";
- var form = document.createElement("form");
- //move the submit function to another variable
- //so that it doesn't get written over if a parameter name is 'submit'
- form._submit_function_ = form.submit;
- form.setAttribute("method", method);
- form.setAttribute("action", path);
- for(var i = 0; i < params.length; i++)
- {
- var key = params[i];
- var hiddenField = document.createElement("input");
- hiddenField.setAttribute("type", "hidden");
- hiddenField.setAttribute("name", key);
- hiddenField.setAttribute("value", params[key]);
- form.appendChild(hiddenField);
- }
- document.body.appendChild(form);
- form._submit_function_(); //call the renamed function
- }
Add Comment
Please, Sign In to add comment