How to redirect webpage via CSS?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • davincourtney
    New Member
    • Jan 2010
    • 1

    How to redirect webpage via CSS?

    I posted this code into a htm. file and I added on my website so i can redirect that page every time somebody access it .

    Now can anybody tell me what code should I put into the "lutu1.css" file so I can get the redirection of my page for example to www. google. com

    Code:
    <P>
      <STRONG>
        <head>
          <link type="text/css" href="http://mydomainname.com/pic1/lutu1.css" media="all"
    rel="stylesheet">
        </head>
    Last edited by Frinavale; Jan 25 '10, 03:35 PM. Reason: Please post code in [code] ... [/code] tags. Added code tags.
  • sanjib65
    New Member
    • Nov 2009
    • 102

    #2
    You can use the HtttpServerUtil ity.Transfer method to halt the code running on the current web page and request that a different web page or web site (as you said, www.google.com) carry on the processing.

    But my question is, why you chose a CSS file to do this thing?

    Comment

    • Frinavale
      Recognized Expert Expert
      • Oct 2006
      • 9749

      #3
      Davincourtney,

      This HTML code is completely invalid.
      You cannot have a <P> element or a <Strong> tag in/around the <head> section. These tags can only be used in the <body> section of the HTML.

      This isn't even a CSS related question...I don't even think your page will work with this because it is so invalid.

      What are you trying to do?

      -Frinny

      Comment

      • Niheel
        Recognized Expert Moderator Top Contributor
        • Jul 2005
        • 2433

        #4
        I think he is trying to redirect his webpage to google via CSS. Or he could just be trying to link to google.

        I don't think that's possible.

        If you want to redirect via HTML you have to put the following code at the top inbetween <head> </head>
        Code:
        <meta HTTP-EQUIV="REFRESH" content="0; url=http://www.yourdomain.com/index.html">
        If you want to link to website like google you have to use the code below. The url inside the href=" " is the destination webpage.

        Code:
        <a href="http://www.google.com">going to google now</a>
        niheel @ bytes

        Comment

        • Frinavale
          Recognized Expert Expert
          • Oct 2006
          • 9749

          #5
          Ahh, that does make more sense.

          Please note that CSS stands for "Cascading Style Sheets". This is used for setting the style for HTML elements on the page (for example you can set the background-color property using CSS). You cannot use CSS to redirect to another web page.

          If you want to redirect, you can use the HTML code that Kub has posted. Or you can do this server side as sanjib65 suggested.

          You could use the Server.Transfer () method but only if you are "transferri ng" the user from web page in your website to another web page in your website.

          If you are trying to redirect the user to a webpage/website that is out side of your website/server then you need to use the Server.Redirect () method.

          -Frinny

          Comment

          • drhowarddrfine
            Recognized Expert Expert
            • Sep 2006
            • 7434

            #6
            Well, in Apache, it's one line in the htaccess file.

            You can add a link with CSS but what a user would still have to click it.

            Comment

            Working...