Web Analytics Made Easy -
StatCounter StyleSwitch works local but not on server? - CodingForum

Announcement

Collapse
No announcement yet.

StyleSwitch works local but not on server?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • StyleSwitch works local but not on server?

    I have added a style switching script to my website and it works fine run locally but will not do anything on the server, Why?

    Code:
    [/<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    <title>Martyn Lee Ball - 3D</title>
    <link href="style.css" rel="stylesheet" type="text/css" />
    <link href="alt-styles/red.css" rel="alternate stylesheet" type="text/css" title="red">
    <link href="alt-styles/green.css" rel="alternate stylesheet" type="text/css" title="green">
    <link href="alt-styles/pink.css" rel="alternate stylesheet" type="text/css" title="pink">
    <script type="text/javascript" src="styleswitcher.js"></script>
    </head>
    <body>
    <a href="#" 
    onclick="setActiveStyleSheet('default'); return false;" rel="nofollow">Blue</a> 
    <a href="#" 
    onclick="setActiveStyleSheet('red'); return false;" rel="nofollow">Red</a> 
    <a href="#" 
    onclick="setActiveStyleSheet('green'); return false;" rel="nofollow">Green</a> 
    <a href="#" 
    onclick="setActiveStyleSheet('pink'); return false;" rel="nofollow">Pink</a>
    <a name="top"></a>
    <!--TITLE TABLE!-->
    <table border="1" width="700" height="auto" align="center" bordercolor="#446688">	
    <td>
    <div class="title">
      <div align="center">MARTYN LEE BALL</div>
      <div class="title-caption">THIS WEBSITE WILL CONTAIN ALL OF MY WORK WITHIN THE MDEIA TOPICS, SUCH AS: 3D MODELS, TEXTURES, ANIMATIONS, ECT... PLEASE CHECK BACK FOR UPDATES, AS I WILL UPDATE WHEN EVER I CREATE SOMETHING NEW.</div>
    </div>
    </td>
    <tr></tr>
    </table>
    <!--TITLE TABLE END!-->
    &nbsp; &nbsp;
    <table class="navbar" width="700" align="center" border="0">
    <tr>
    <td>
    <div class="navbar-text" align="center">
    <a href="index.php">Home</a> | 
    <a href="3d.php">3D Models</a>(15) | 
    <a href="textures.php">Textures</a>(0) | 
    <a href="2d.php">2D Work</a>(0) | 
    <a href="other.php">Other</a>(0) | 
    <a href="contactme.php">Contact Me</a> | 
    <a href="about.php">About</a>
    </div>
    </tr>
    </td>
    </table>
    <table class="content" width="700" align="center" border="0">
    <tr>
    <td rowspan="2">
    <div class="update">
    UPDATED: THURDAY, 02 APRIL 2009
    </div>
    <div id="txt"></div>
    <div class="main-content-title">
    3D Models
    </div>
    <div class="main-content">
    These are my 3D models. I will add the newest at the top of the page.
    </div>
    <?php include "pages/h3hornet.html"; ?> 
    <!--Break!--><?php include "pages/break.html"; ?> <!--Break!-->
    <?php include "pages/h3odstsmg.html"; ?> 
    <!--Break!--><?php include "pages/break.html"; ?> <!--Break!-->
    <?php include "pages/h3missilepod.html"; ?> 
    <!--Break!--><?php include "pages/break.html"; ?> <!--Break!-->
    </td>
    </table>
    <table class="copyright" width="700" align="center" border="0">
    <div class="update" align="center">&copy; COPYRIGHT - MARTYN LEE BALL - 2009</div>
    </table>
    <center>
    <div class="ads">
    <a href="http://www.modacity.net" target="_blank"><img src="images/modacity.jpeg"></a>
    <a href="http://www.halomaps.org" target="_blank"><img src="images/halomaps.jpeg"></a>
    <a href="http://www.modhalo.net/" target="_blank"><img src="images/modhalo.gif"></a>
    <a href="http://www.deviantart.com/" target="_blank"><img src="images/deviantart.jpeg"></a>
    </div>
    </center>
    <?php include "side-bar.html"; ?> 
    </body>
    </html>
    Last edited by martynball; Apr 5, 2009, 09:36 AM.

  • #2
    Code:
    <link href="[ICODE]alt-styles/green.css[/ICODE]"
    Have you uploaded your stylesheets to their corresponding paths? Could you post a link to your page?
    Digitalocean Cloud Hosting (Referral link - get $10 free credit) Fameco

    Comment


    • #3
      http://martynleeball.nxserve.net/martynball/

      Last edited by martynball; Apr 6, 2009, 07:26 AM.

      Comment


      • #4
        Your script has an error,
        Originally posted by Firebug
        missing ; before statement
        Get a copy of firebug for your firefox. I think you have made a mistake while compressing(removing all line breaks in) your javascript, some where at the end.
        Last edited by abduraooft; Apr 6, 2009, 08:45 AM.
        Digitalocean Cloud Hosting (Referral link - get $10 free credit) Fameco

        Comment


        • #5
          I havnt touched the javascript. I just uploaded it. Why was it working locally though?

          Comment


          • #6
            Originally posted by martynball View Post
            I havnt touched the javascript. I just uploaded it. Why was it working locally though?
            No idea about your local files , but in the above given url, there is an error. Have a try by uploading the script from ALA(hope you've got it from there) directly, without making any compression.
            Digitalocean Cloud Hosting (Referral link - get $10 free credit) Fameco

            Comment


            • #7
              Dont think I got it from there. Do you have a link?

              Comment


              • #8
                http://www.alistapart.com/articles/alternate/
                Digitalocean Cloud Hosting (Referral link - get $10 free credit) Fameco

                Comment


                • #9
                  I just tryed that, didnt work. So I put the javascript into the actualy page. And it works. Am I linking to the javascript wrong?

                  Comment


                  • #10
                    When I just put all the codes provided in that website as such, like
                    Code:
                    function setActiveStyleSheet(title) {
                       var i, a, main;
                       for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
                         if(a.getAttribute("rel").indexOf("style") != -1
                            && a.getAttribute("title")) {
                           a.disabled = true;
                           if(a.getAttribute("title") == title) a.disabled = false;
                         }
                       }
                    }
                    function getActiveStyleSheet() {
                    var i, a;
                     for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
                      if(a.getAttribute("rel").indexOf("style") != -1
                      && a.getAttribute("title")
                      && !a.disabled) return a.getAttribute("title");
                      }
                      return null;
                    }
                    function createCookie(name,value,days) {
                      if (days) {
                        var date = new Date();
                        date.setTime(date.getTime()+(days*24*60*60*1000));
                        var expires = "; expires="+date.toGMTString();
                      }
                      else expires = "";
                      document.cookie = name+"="+value+expires+"; path=/";
                    }
                    function readCookie(name) {
                      var nameEQ = name + "=";
                      var ca = document.cookie.split(';');
                      for(var i=0;i < ca.length;i++) {
                        var c = ca[i];
                        while (c.charAt(0)==' ') c = c.substring(1,c.length);
                        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
                      }
                      return null;
                    }
                    function getPreferredStyleSheet() {
                      var i, a;
                      for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
                        if(a.getAttribute("rel").indexOf("style") != -1
                           && a.getAttribute("rel").indexOf("alt") == -1
                           && a.getAttribute("title")
                           ) return a.getAttribute("title");
                      }
                      return null;
                    }
                    window.onload = function(e) {
                      var cookie = readCookie("style");
                      var title = cookie ? cookie : getPreferredStyleSheet();
                      setActiveStyleSheet(title);
                    }
                    window.onunload = function(e) {
                      var title = getActiveStyleSheet();
                      createCookie("style", title, 365);
                    }
                    it works. That's all I know.
                    (I'm running out of time, no way to decompress your current script and isolate the issue, right now )
                    Digitalocean Cloud Hosting (Referral link - get $10 free credit) Fameco

                    Comment


                    • #11
                      Your style sheet tags aren't properly closed.
                      Code:
                      <link href="alt-styles/red.css" rel="alternate stylesheet" type="text/css" title="red"[COLOR="Red"]/[/COLOR]>
                      <link href="alt-styles/green.css" rel="alternate stylesheet" type="text/css" title="green"[COLOR="Red"]/[/COLOR]>
                      <link href="alt-styles/pink.css" rel="alternate stylesheet" type="text/css" title="pink"[COLOR="Red"]/[/COLOR]>

                      Comment


                      • #12
                        I opened the javascript file and pasted in what you put abduraooft and it works now, thanks. I will make sure they are closed right as well F-b0mb. Thanks.

                        Comment

                        Working...
                        X