Parse JS How to get the parameter value in the current URL and copy it to Input_ basics

Source: Internet
Author: User
Tags html page
Copy Code code as follows:

function GetObject (objectId) {
if (document.getElementById && document.getElementById (objectId)) {
return document.getElementById (OBJECTID);
else if (document.all && document.all (objectId)) {
return document.all (OBJECTID);
else if (document.layers && Document.layers[objectid]) {
return Document.layers[objectid];
} else {
return false;
function Get (p) {
var url= document. Url.tostring ();
var tmpstr=p+ "=";
var tmp_reg=eval ("/[\?&]" +tmpstr+ "/I");
if ( (Tmp_reg) ==-1) return null;
var a=url.split (/[\?&]/);
for (Var i=0;i<a.length;i++)
if (A[i].search (eval ("/^" +tmpstr+ "/I")!=-1) return a[i].substring (tmpstr.length);
Window.onload=function () {

GetObject ("key"). Value = Get ("K");
Key as the name of input, the value received is the browser in the K parameter
K is the name of the parameter in the browser

The above code is placed at the bottom of the HTML page

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.