search

Home  >  Q&A  >  body text

location.href = '/m/';//How to write the current page url code

<script type="text/javascript">

(function(){

    var sUserAgent = navigator.userAgent;

    if (sUserAgent.indexOf('Android') > -1 && sUserAgent.indexOf('Mobile') > -1 || sUserAgent.indexOf('iPhone') > -1 || sUserAgent.indexOf('iPod') > -1 || sUserAgent.indexOf('iPad') > -1 || sUserAgent.indexOf('Symbian') > -1 || sUserAgent.indexOf('IEMobile') > -1)

{

document.write(location.search);

location.href = '/m/';//�%8

一个字一个字2064 days ago1489

reply all(3)I'll reply

  • 秋香姐家的小书童

    秋香姐家的小书童2019-09-03 19:47:58

    1

    2

    3

    4

    5

    6

    7

    8

    9

    10

    11

    12

    13

    14

    15

    16

    17

    18

    19

    20

    21

    22

    //获取当前窗口的

    Urlvar url = window.location.href;

    //结果: 

    获取当前窗口的主机名

    var host = window.location.host;

    //结果:

    localhost:61768

    //获取当前窗口的端口

    var port = window.location.port;

    //结果:61768

    //获取当前窗口的路径

    var pathname = window.location.pathname;

    //结果:

    /Home/Index

    //获取当前文档的

    Urlvar URL = document.URL;

    //结果:

    http://localhost:61768/Home/Index?id=2&age=18

    //获取参数

    var search = window.location.search;

    //结果:

    ?id=2&age=18


    reply
    0
  • 一个字

    Dear, I can’t write, please write.

    一个字 · 2019-09-03 20:39:19
    一个字

    Still here,

    一个字 · 2019-09-10 10:00:14
  • Cancelreply