简体   繁体   English

根据屏幕大小为单个网站设置多个主页

[英]Multiple Homepages for single website according to screen size

I have made font end of website(static website).我已经制作了网站(静态网站)的字体结尾。 I want to make multiple home pages for this website according to screen size.我想根据屏幕大小为这个网站制作多个主页。 for example homepage1.html for mobile screen size and homepage2.html for desktop, and remaining pages(services, contact) would be same for all screen size.例如,移动屏幕尺寸的 homepage1.html 和桌面设备的 homepage2.html,其余页面(服务、联系人)对于所有屏幕尺寸都是相同的。

so please help me how to do this without using php?所以请帮助我如何在不使用 php 的情况下做到这一点?

in php we can import like this在php中我们可以像这样导入

<?php include('homepage1.php') ?>

i want to do this same thing using html or js, then i can write function in js like if screen size is less than 700px then import homepage1.html.我想用 html 或 js 做同样的事情,然后我可以在 js 中编写函数,比如如果屏幕尺寸小于 700px 然后导入 homepage1.html。

If you have any other idea to do this same thing then please guide me..如果您有任何其他想法来做同样的事情,请指导我..

Thank you in advance :)先感谢您 :)

You can do it by adding a simple code.您可以通过添加一个简单的代码来实现。 You can add more screen width.您可以添加更多屏幕宽度。

<script type="text/javascript">
    $(window).on('load resize',function(){
        if($(window).width() < 950){
            window.location = "https://www.google.com"
        }
    });
</script>

Such as

// In index2.php
if (window.innerWidth < 960) {
    window.location = "index1.php";
}

// In index1.php
if (window.innerWidth >= 960) {
    window.location = "index2.php";
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM