Home > Software engineering >  How to open item in new page for more details
How to open item in new page for more details

Time:02-26

I want to open item in new page when visitor will click btn with icon search. I want redirect just item1 to new page and show more details about item1. I saw same solutions like: window.location='app2.html; or location.replace('https://...') Is better way to do it ?

   //app1.html  page1
    <div >
     
       // item 1
         <div >
          <img src="..." alt="..."><br>
          <button >
            <i  data-id="1"></i>   // here is btn with id
          </button>
         </div>

       // item2, ...

    </div>


  //app2.html page2  // new page 
  

CodePudding user response:

You can use window.location.href = "app2.html"; inside an implicit function in js.

 
function test(){
    window.location.href = "http://www.devmedia.com.br";
}
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>

    <script src="test.js"></script>

</head>
<body>
    <button onclick="test()">Btn</button>
</body>
</html>

  • Related