You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在javascript:open链接中正确嵌入GEO_LATITUDE和GEO_LONGITUDE变量值

First, let's break down the key issues in your current code that are preventing the variables from being embedded correctly:

  • You’re using #GEO_LONGITUDE# and #GEO_LATITUDE#, which isn’t valid JavaScript syntax for inserting variables—we need to use string concatenation with the + operator instead.
  • The string quotes are mismatched: you close the URL string too early before adding the variables, causing syntax errors.
  • There’s an extra ','+', ' segment that breaks the flow of the URL construction.
  • window.innerheight has a typo—it should be window.innerHeight (capital "H" is required for this browser API).
  • You’re missing a comma between the width and resizable properties in the window features string.

Here’s the corrected code that properly inserts your variables and fixes all the syntax issues:

javascript:open('http://maps.google.com/maps?q=' + GEO_LONGITUDE + '+' + GEO_LATITUDE, 'popup-example', 'height=' + window.innerHeight + ',width=' + window.innerWidth + ',resizable=no')

How this works:

  • We start the URL string with 'http://maps.google.com/maps?q='
  • Concatenate the GEO_LONGITUDE variable using +
  • Add the required + separator as a string ('+')
  • Concatenate the GEO_LATITUDE variable to complete the query parameter
  • Fix the window feature string by correcting the innerHeight typo and adding the missing comma before resizable=no

For your example values (46.15 and 50), this code will generate exactly the link you want:

javascript:open('http://maps.google.com/maps?q=46.15+50', 'popup-example', 'height='+window.innerHeight+',width='+window.innerWidth+',resizable=no')

Just double-check that GEO_LATITUDE and GEO_LONGITUDE are properly defined variables in the context where this link runs—otherwise, you’ll see undefined in the URL instead of your values.

内容的提问来源于stack exchange,提问作者Andrii Havrylyak

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.14 09:02:38