dqyuipw44576 2016-08-22 10:25
浏览 46
已采纳

如何在警报脚本中插入GEOIP标注?

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.

<head>
<script type="text/javascript" src="http://www.jsgeoip.com/geoip.js">   </script>
</head>
<body>
<script> 
$(document).ready(function() {
$('#city').html(geoip_city());
}); 
</script>
<script>alert('Welcome CITY HERE User');</script>
</body>
  • 写回答

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();
        $('#city').html(geoip);
        alert('Welcome ' + geoip + ' User');
    });
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 Stata 面板数据模型选择
  • ¥20 idea运行测试代码报错问题
  • ¥15 网络监控:网络故障告警通知
  • ¥15 django项目运行报编码错误
  • ¥15 请问这个是什么意思?
  • ¥15 STM32驱动继电器
  • ¥15 Windows server update services
  • ¥15 关于#c语言#的问题:我现在在做一个墨水屏设计,2.9英寸的小屏怎么换4.2英寸大屏
  • ¥15 模糊pid与pid仿真结果几乎一样
  • ¥15 java的GUI的运用