2016-08-22 10:25
浏览 46


I'm looking for a way to call out the user's city within the alert script, I have tried document.write but I'm no coder and spent several hours to no avail. I can use

<span id="city">{cityname}</span> 

on the page itself, but cannot get it to work in the alert script.

<script type="text/javascript" src="http://www.jsgeoip.com/geoip.js">   </script>
$(document).ready(function() {
<script>alert('Welcome CITY HERE User');</script>
  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • doujia1679 2016-08-22 10:30

    Just move the alert call to after you get the geoip. No use having that second script block, do it all in the one ready function:

    $(document).ready(function() {
        var geoip = geoip_city();
        alert('Welcome ' + geoip + ' User');
    点赞 评论

相关推荐 更多相似问题