且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

有没有办法在 url 中传递 javascript 变量?

更新时间:2022-05-28 00:45:48

试试这个:

 window.location.href = "http://www.gorissen.info/Pierre/maps/googleMapLocation.php?lat="+elemA+"&lon="+elemB+"&setLatLon=Set";

要将变量放入字符串中,请将变量用引号和加号括起来,如下所示:

To put a variable in a string enclose the variable in quotes and addition signs like this:

var myname = "BOB";
var mystring = "Hi there "+myname+"!"; 

只要记住一个规则!