Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
325 views
in Technique[技术] by (71.8m points)

Change JavaScript variable value by passing new values inside URL ( GET request )

I have an i frame which has a src called map.php.

  <iframe src= "map.php " ></iframe>

Inside map.php i have a variable called map. I want to change the value of "center " inside the map variable to something new when the src load up

map.php (javascript)

var map = new mapboxgl.Map({


 center: [115.83333, -32.01667], 
    
 
});

So my question is whether i can pass some parameter values along with src = map.php to change the center value

example. ( Just my concept )

 <iframe  src= "map.php/parameter center[new values] " ></iframe>
question from:https://stackoverflow.com/questions/66057989/change-javascript-variable-value-by-passing-new-values-inside-url-get-request

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

you can pass values in query param by constructing the url like this:

map.php/parameter?cx=115.83333&cy=-32.01667

Again in the php script you can access these values from query params using $_SERVER['QUERY_STRING']. Just parse,extract and use the values inside php file.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...