search
HomeWeb Front-endJS TutorialJavascript Gets HTML Static Page Parameter Pass Value Example_javascript Tips

Let me show you my code. Just embed these codes into the page file.

Example 1
Use regular expressions to get

Copy code The code is as follows:

var LocString = String(window.document.location.href);
function getQueryStr(str) {
var rs = new RegExp("(^|)" str "=([^&]*)(&|$)", "gi").exec(LocString), tmp;
if ( tmp = rs) {
return tmp[2];
}
// parameter cannot be found
return "";
}

Call method
Copy code The code is as follows:

document.getElementById("user").value = getQueryStr( "user");
document.getElementById("password").value = getQueryStr("password");
document.getElementById("sysno").value = getQueryStr("sysno");

Example 2
Use the split function to cut into arrays according to parameters
Copy code The code is as follows:

<script> <BR>urlinfo=window.location.href; //Get the url of the current page <BR>len=urlinfo.length;//Get the url Length<BR>offset=urlinfo.indexOf("?");//Set the starting position of the parameter string<BR>newsidinfo=urlinfo.substr(offset,len)//Remove the parameter string and you will get something like "id= 1" such a string<BR>newsids=newsidinfo.split("=");//Split the obtained parameter string according to "="<BR>newsid=newsids[1];//Get the parameter value<BR>alert("The parameter value you want to pass is " newsid); <BR></script>

But be sure to remember that this method is only useful for urls that contain parameters. If the other party uses If you use the POST method to pass parameters, the URL will not contain parameters, so this technique is only useful for the GET method or the URL with specified parameters

Look at a complete example below

aa.htm It is the parameter input and infiltration interface
bb.htm is the parameter receiving and processing interface
aa.htm
Copy code The code is as follows:


()
 {
 var input1 = document.getElementById("inputid");
 window.open("bb.htm?inputStr=" input1.value); // Pass in parameters
 }
 
 
  
 
Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
优化Golang函数参数传递性能的最佳实践优化Golang函数参数传递性能的最佳实践Apr 13, 2024 am 11:15 AM

为了优化Go函数参数传递性能,最佳实践包括:使用值类型避免复制小型值类型;使用指针传递大型值类型(结构体);使用值类型传递切片;使用接口传递多态类型。在实践中,传递大型JSON字符串时,传递data参数指针可以显著提高反序列化性能。

C++ 函数参数详解:并行编程中参数传递的性能优化C++ 函数参数详解:并行编程中参数传递的性能优化Apr 27, 2024 pm 02:09 PM

多线程环境中,函数参数传递方式不同,性能差异显著:按值传递:复制参数值,安全,但大型对象开销大。按引用传递:传递引用,效率高,但函数修改会影响调用者。按常量引用传递:传递常量引用,安全,但限制函数对参数操作。按指针传递:传递指针,灵活,但指针管理复杂,可能出现悬垂指针或内存泄漏。并行求和中,按引用传递效率优于按值传递,按指针传递灵活度最高,但管理复杂。

Go语言中的参数传递方式探究Go语言中的参数传递方式探究Apr 03, 2024 pm 02:48 PM

在Go语言中,函数参数的传递方式主要有两种:值传递:传递变量的副本,不会影响调用代码中的原始变量。指针传递:传递变量的地址,允许函数直接修改调用代码中的原始变量。

C++ 函数指针参数传递机制C++ 函数指针参数传递机制Apr 19, 2024 pm 02:06 PM

C++中函数指针作为参数传递机制:将函数指针作为常量指针传递,传递过程中创建副本,接收函数形式参数指向副本,解引用副本可调用底层函数。

golang函数映射作为参数传递golang函数映射作为参数传递Apr 22, 2024 am 11:42 AM

在Go中,函数映射可作为函数的参数传递,提供代码重用和定制功能:创建函数映射:使用map[string]interface{}类型,将函数名称作为键,函数本身作为值存储。作为参数传递:在函数参数列表中使用funcMap类型来接受函数映射。执行函数:通过reflect包从函数映射中检索函数,并使用变量参数调用它。实战案例:函数映射可传递给模板引擎,在运行时动态执行模板函数。

C++ 函数参数传递方式与可变参数函数的关系C++ 函数参数传递方式与可变参数函数的关系Apr 13, 2024 am 08:30 AM

函数参数传递方式包括值传递、引用传递和指针传递,其中可变参数函数只能以指针传递方式传入参数,因为函数需要知道可变参数部分的地址。例如,sum()函数使用...接受数量未知的参数,然后使用va_arg()宏获取可变参数的值。

PHP 函数的参数传递方式是什么?PHP 函数的参数传递方式是什么?Apr 10, 2024 am 11:06 AM

PHP参数传递有两种方式:传值调用(参数作为值的副本传递,函数内修改不影响原变量)和引用传递(参数的地址传递,函数内修改会影响原变量),在需要修改原变量的情况下使用引用传递,如购物车总价计算时需要引用传递才能正确计算。

如何传递参数到 PHP 函数?如何传递参数到 PHP 函数?Apr 10, 2024 pm 05:21 PM

PHP函数可以通过参数传递值,分为按值传递和按引用传递:按值传递:函数内部对参数修改不会影响原始值;按引用传递:函数内部对参数修改会影响原始值。此外,还可以传递数组作为参数,用于计算数据总和等操作。

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
Repo: How To Revive Teammates
1 months agoBy尊渡假赌尊渡假赌尊渡假赌
Hello Kitty Island Adventure: How To Get Giant Seeds
4 weeks agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

VSCode Windows 64-bit Download

VSCode Windows 64-bit Download

A free and powerful IDE editor launched by Microsoft