Use JS to dynamically modify the url to add, query, modify, and delete the url.
Although you can modify the url dynamically by submitting a post form using the get method, if multiple buttons can be submitted in parallel, write multiple forms with the same details and differences, it is inevitable that there is something wrong. Therefore, I thought of using JS to dynamically modify the url to add, query, modify, and delete the url.
<Script> var LG = (function (lg) {var objURL = function (url) {this. ourl = url | window. location. href; this. href = "";//? Previous section this. params = {}; // url parameter object this. jing = ""; // # And this. init ();} // analyze the url? Save this. href. The parameter is resolved to this. params object, # And save it to this. jing objURL. prototype. init = function () {var str = this. ourl; var index = str. indexOf ("#"); if (index> 0) {this. jing = str. substr (index); str = str. substring (0, index);} index = str. indexOf ("? "); If (index> 0) {this. href = str. substring (0, index); str = str. substr (index + 1); var parts = str. split ("&"); for (var I = 0; I <parts. length; I ++) {var kv = parts [I]. split ("="); this. params [kv [0] = kv [1] ;}} else {this. href = this. ourl; this. params = {};}// only modify this. params objURL. prototype. set = function (key, val) {this. params [key] = val;} // only sets this. params objURL. prototype. remove = function (key) {this. params [key] = undef Ined;} // The url objURL after the three-part operation. prototype. url = function () {var strurl = this. href; var objps = []; // The array is used here, And the join operation for (var k in this. params) {if (this. params [k]) {objps. push (k + "=" + this. params [k]) ;}} if (objps. length> 0) {strurl + = "? "+ Objps. join ("&");} if (this. jing. length> 0) {strurl + = this. jing;} return strurl;} // obtain the parameter value objURL. prototype. get = function (key) {return this. params [key];} lg. URL = objURL; return lg ;}( LG ||{}); var myurl = new LG. URL (window. location. href); myurl. remove ("B"); // Delete B alert (myurl. get ("a"); // obtain the value of parameter a. Here, 1 myurl is obtained. set ("a", 23); // modify the value of a to 23 alert (myurl. url (); </script>
JavaScript to implement dynamic URLs
Adding javascript scripts in href does not work. Dynamic URLs can be implemented only when a function is called by triggering an event. Below is an implementation method.
<Script language = "javascript">
Var tempUrl = "";
Function addText (obj ){
TempUrl = obj. href;
Obj. href + = obj. innerText;
}
Function delText (obj ){
Obj. href = tempUrl;
}
</Script>
<A href = "www.abc.com #" onmouseover = "addText (this)" onmouseout = "delText (this)">
Link text
</A>
If the URL is known, how can I download the URL in byte stream format using js or HTTP protocol change?