为共享自己的网站创建一个widgest [英] create a widgest for share own website

查看:81
本文介绍了为共享自己的网站创建一个widgest的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想创建自己的widgest来共享其他网站,例如facebook和twitter提供了一个widgest,以便我要创建自己的网站时要键入widgest.您将需要使用Javascript来执行此操作,但是也可以使用PHP.

这是一个在页面上显示您的IP地址的示例. (注意:这可以完全用JS完成,但使用PHP进行演示)

index.html

 <!-  这是在页面上显示小部件的代码 ->  
<  脚本    ="  文本/javascript"  src    ip .php" <  / 脚本 >  



ip.php

 // 这仅仅是通过API获取用户IP 
 


ip = file_get_contents(' ?>


 // 这将JS变量ip设置为等于php变量ip 
 var  ip = ' <?php echo  

ip; ??>'; // 这会将您的IP写入文档,以便可以显示. 文档 .write(' 您的IP地址为-' + ip);


i want to create own widgest for sharing other website , like facebook and twitter provide a widgest so that type widgest i want to create to own website.

解决方案

You will need to use Javascript to do this however PHP can be used as well.

Here is an example that displays your IP address on the page. (note: this could be done completely with JS but using PHP for demonstration purposes)

index.html

<!--This is the code that shows the widget on the page-->
<script type="text/javascript" src="ip.php"></script>



ip.php

//This is just to get the users IP via an API


ip = file_get_contents('http://api.externalip.net/ip/'); ?>


//This sets the JS variable ip equal to the php variable ip
var ip = '<?php echo


ip; ??>'; //This writes your IP to the document so that it can be displayed. document.write('Your IP address is - ' + ip);


这篇关于为共享自己的网站创建一个widgest的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆