search

Home  >  Q&A  >  body text

javascript - Ask for advice: How to display the originally hidden div of page 2 when linking from page 1 to page 2?

Can it be done purely using js and html?
One way that comes to mind is to use the form on page one to pass parameters, and page two to judge the parameters to determine whether p is displayed.
But how are the parameters passed by action received by page 2?

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8"/>
    <title></title>
    
</head>
<body>

<form action="index2.html#p">
<input type="text" name="firstname" value="">
<input type="submit" value="Submit">
</form> 

</body>
</html>

Please tell me, seniors, whether this method is feasible? How to do it?

迷茫迷茫2701 days ago801

reply all(2)I'll reply

  • 女神的闺蜜爱上我

    女神的闺蜜爱上我2017-07-05 10:56:05

    Get url parameters

    
    function GetQueryString(name)
    {
         var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
         var r = window.location.search.substr(1).match(reg);
         if(r!=null)return  unescape(r[2]); return null;
    }
     
    // 调用方法
    alert(GetQueryString("参数名1"));
    alert(GetQueryString("参数名2"));
    alert(GetQueryString("参数名3"));

    reply
    0
  • 怪我咯

    怪我咯2017-07-05 10:56:05

    One more thing, CSS3’s :target pseudo-class selector can also implement this function, mainly using anchor points

    Reference: http://css.doyoe.com/selector...

    reply
    0
  • Cancelreply