简体   繁体   中英

.net page redirect based on screen width based from codebehind

Is there a way that I can do redirect from codebehind based on screen width? Currently, I am using javascript to do something like this:

 <script type="text/javascript">
        <!--
        if (screen.width <= 699) {
            document.location = "http://blahblahblah.com";
        }
        //-->
</script>

The page that is hosting this is under SSL, and all links on the front end need to show https, or else it breaks the security of the page. The url I am attempting to redirect to is NOT under SSL, and I have no ability to change that. If I do the redirect from the codebehind, it won't break security to pass off to an unsecured site. Any suggestions?

Here's a good example from what you want to do:

Calling a webmethod with jquery in asp.net webforms

Just add width as a parameter and do what you need.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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