A.h HTML code is as follows: click on the button to adjust to the b.h HTML page, and then passed the json
<script> {$. Alarmctrl=function (ctrldata) The console. The log (ctrldata); Var url="b.h HTML? Ctrldata="HTTP://https://bbs.csdn.net/topics/+encodeURI (ctrldata); The location. The href=https://bbs.csdn.net/topics/url; } </script> B.h HTML code is as follows:
<script> //receive the json array Var param=decodeURI (location. Search); If (param!=null & & Param! { ="")Param=param. Substring (param. IndexOf ("=") + 1, param. Length); Alert (param); Alert (JSON. Stringify (param)); } </script> For help, b.h HTML how to obtain the json data, thank you! The above code is not an error, but the result is wrong,
CodePudding user response:
Big game world?
CodePudding user response:
As A and B are introduced into the same A JS then operate?
CodePudding user response:
refer to the original poster fangsky response: A.h HTML code is as follows: click on the button to adjust to the b.h HTML page, and then get passed the json <script> {$. Alarmctrl=function (ctrldata) The console. The log (ctrldata); Var url="b.h HTML? Ctrldata="HTTP://https://bbs.csdn.net/topics/+encodeURI (ctrldata); The location. The href=https://bbs.csdn.net/topics/url; } </script> B.h HTML code is as follows: <script> //receive the json array Var param=decodeURI (location. Search); If (param!=null & & Param! { ="")Param=param. Substring (param. IndexOf ("=") + 1, param. Length); Alert (param); Alert (JSON. Stringify (param)); } </script> You're just For help, b.h HTML how to obtain the json data, thank you! The above code is not an error, but the result is wrong, Do you want to transfer an object to b.h HTML ctrldata parameters on duty, but is an object, you send encodeURI method can not get the results you want, you can either use JSON. The first stringifyl into a string, get url parameter and then JSON. Parse back Or don't attached to the directly? ctrldata=https://bbs.csdn.net/topics/behind the duty, direct: Object. Keys (ctrldata). The map (key=& gt; Key + '=' + ctrldata [key]). Join (' & amp; ') , Generate B.h HTML? ServerPort1=10202 & amp; ServerPort2=10203 & amp; CtrlType=3 & amp; ServerIP=192.168.1.18 & amp; CtrlID=105 So the conventional url good Then you're b.h went to read in the TML ServerPort1, ServerPort2