代码之家  ›  专栏  ›  技术社区  ›  raviramani

单击<a>标记时在目标页上应用脚本

  •  1
  • raviramani  · 技术社区  · 6 年前

    .orange 从destination page slider.html。

    page1.html

    <body>    
        <a  class="slider" href="slider.html"> goto slider </a>
        <div class="red"></div>
        <div class="blue"></div>
        <div class="yellow"></div>
    </body>
    

    滑块.html

    <body>
        <a class="page1" href="page1.html"> goto page1 </a>
        <div class="green"></div>
        <div class="orange"></div>
        <div class="black"></div>
    </body>
    

    .red,.blue,.yellow,.green,.orange,.black {
        width: 100%;
        height: 150px;
    }
    .red {
        background: red;
    }
    .blue {
        background: blue;
    }
    .yellow{
        background: yellow;
    }
    .green{
        background: green;
    }
    .orange{
        background: orange;
    }
    .black {
        background: black;
    }
    

    js公司

    $(document).ready(function(){
        $('body').on('click','.slider',function(){
            console.log('clicked');
            $('.orange').remove();
        });
    });
    

    告诉我如何在两个html文件之间进行通信,或者如何在目标页加载完成后重新加载脚本

    window.onload document.ready 但它们只在当前页面上有效,不影响目标页面,

    提前谢谢。

    0 回复  |  直到 6 年前