爱意满满的作品展示区。
Lentin

一个简易的 PC 浏览器同步手机当前打开网页的方案

  •  
  •   Lentin · Apr 22, 2018 · 5539 views
    This topic created in 3118 days ago, the information mentioned may be changed or developed.
    有时候 PC 上浏览了个页面想在手机上打开,但是 PC 的 Chrome 跟手机 Safari 的历史记录没有同步,扫二维码也不是特别方便,我做了个书签,搭配一个 php 使用。

    php 源文件如下,只是获取 url 之后写到一个 txt 里面暂存 url
    u.php
    <?php
    header('Access-Control-Allow-Origin:*');
    if ($_GET["url"]) {
    fwrite(fopen("url.txt","w"),$_GET["url"]);
    echo "Success";
    } else {
    header('Location: '.file_get_contents('url.txt'));
    }
    ?>

    Crhome 书签地址如下

    javascript:xmlhttp=new XMLHttpRequest();xmlhttp.open("get","https://yourdomain/u.php?url="+window.location.href,true);xmlhttp.send();xmlhttp.onreadystatechange=function(){if (xmlhttp.readyState==4 && xmlhttp.status==200){alert("ok");}}

    实现的结果就是流量器上点一下书签,然后手机上访问 https://yourdomain/u.php 就能跳转到你当前标记的网页了。
    由于技术不到位,功能简陋,思路大概是这样,有大佬优化一下就更好了……
    16 replies  •  2018-04-22 21:20:06 +08:00
    huangtao728
    huangtao728
    Apr 22, 2018 via Android
    1
    思路简洁,我觉得不错
    ilay1678
    ilay1678
    Apr 22, 2018 via Android
    2
    反过来手机浏览的网页同步到电脑呢
    summerwar
    summerwar
    Apr 22, 2018
    3
    @ifwangs 分享网址到手机 QQ
    Lentin
    Lentin
    OP
    Apr 22, 2018
    4
    @ifwangs 同理,把后面 javascript:书签加到手机……
    ctt
    ctt
    Apr 22, 2018
    5
    不知咋的有的页面点了书签不会 ok
    Chingim
    Chingim
    Apr 22, 2018 via Android
    6
    这个需求我一般用 pushbullet
    Lentin
    Lentin
    OP
    Apr 22, 2018
    7
    @ctt F12 查错吧
    ctt
    ctt
    Apr 22, 2018
    8
    VM125:1 Mixed Content: The page at 'https://www.v2ex.com/t/448807#reply7' was loaded over HTTPS, but requested an insecure XMLHttpRequest endpoint 'http://?url=https://www.v2ex.com/t/448807'. This request has been blocked; the content must be served over HTTPS.

    我的网站没 https 的原因
    Lentin
    Lentin
    OP
    Apr 22, 2018
    9
    @ctt 随便找个支持 https 免费空间就行了,也没啥负载
    ctt
    ctt
    Apr 22, 2018
    10
    没找到啊。。不过小小改动,也凑合用用了
    php 的 echo "Success"; 改成 header('Location: '.$_GET["url"]);

    书签改成
    javascript:window.location.href="http://xxx/?url="+encodeURIComponent(window.location.href)

    就是比 https 方案多刷新了下页面
    lvsemi1
    lvsemi1
    Apr 22, 2018 via Android
    11
    firefox->发送到其他设备
    goreliu
    goreliu
    Apr 22, 2018
    12
    @ctt 支持 https 的免费空间的话,可以用 coding.net 的 “动态 Pages ”,功能比较弱,只支持 php,不支持访问网络,只有 128 MB 本地空间(每次更新代码都会清空)和 128 MB MySQL 空间。之前一直没想到怎么利用,但用这个倒是可以。
    cctv6
    cctv6
    Apr 22, 2018 via iPhone
    13
    想法很好
    HangoX
    HangoX
    Apr 22, 2018 via Android
    14
    默默的用 chrome
    Epsil0n9
    Epsil0n9
    Apr 22, 2018
    15
    @Chingim 记得以前 pb 上自动同步的短信内容无法手动删除,当时感到非常无语
    XnEnokq9vkvVq4
    XnEnokq9vkvVq4
    Apr 22, 2018
    16
    作为临时方案很不错
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Privacy   ·   Solana   ·   2796 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 54ms · UTC 14:33 · PVG 22:33 · LAX 06:33 · JFK 09:33
    ♥ Do have faith in what you're doing.