ThinkChat2.0新版上线,更智能更精彩,支持会话、画图、阅读、搜索等,送10W Token,即刻开启你的AI之旅 广告
# html本地传输数据 ``` <pre class="calibre15">``` <span class="token2">function</span> <span class="token3">getQueryVariable</span><span class="token1">(</span><span class="token1">)</span> <span class="token1">{</span> <span class="token2">let</span> href \<span class="token">=</span> window<span class="token1">.</span>location<span class="token1">.</span>href <span class="token2">let</span> query \<span class="token">=</span> href<span class="token1">.</span><span class="token3">substring</span><span class="token1">(</span>href<span class="token1">.</span><span class="token3">indexOf</span><span class="token1">(</span><span class="token4">'?'</span><span class="token1">)</span> <span class="token">+</span> <span class="token5">1</span><span class="token1">)</span><span class="token1">;</span> <span class="token2">let</span> vars \<span class="token">=</span> query<span class="token1">.</span><span class="token3">split</span><span class="token1">(</span><span class="token4">"&"</span><span class="token1">)</span><span class="token1">;</span> <span class="token2">let</span> obj \<span class="token">=</span> <span class="token1">{</span><span class="token1">}</span> <span class="token2">for</span> <span class="token1">(</span><span class="token2">var</span> i \<span class="token">=</span> <span class="token5">0</span><span class="token1">;</span> i <span class="token"><</span> vars<span class="token1">.</span>length<span class="token1">;</span> i<span class="token">++</span><span class="token1">)</span> <span class="token1">{</span> <span class="token2">let</span> pair \<span class="token">=</span> vars\<span class="token1">[</span>i\<span class="token1">]</span><span class="token1">.</span><span class="token3">split</span><span class="token1">(</span><span class="token4">"\="</span><span class="token1">)</span><span class="token1">;</span> obj\<span class="token1">[</span>pair\<span class="token1">[</span><span class="token5">0</span>\<span class="token1">]</span>\<span class="token1">]</span> \<span class="token">=</span> pair\<span class="token1">[</span><span class="token5">1</span>\<span class="token1">]</span> <span class="token1">}</span> <span class="token2">return</span> obj<span class="token1">;</span> <span class="token1">}</span> ``` ```