Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 12 of 12
  1. #1
    Regular Coder
    Join Date
    Nov 2007
    Posts
    682
    Thanks
    319
    Thanked 1 Time in 1 Post

    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; 04-05-2009 at 02:36 PM.

  • #2
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,861
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Code:
    <link href="alt-styles/green.css"
    Have you uploaded your stylesheets to their corresponding paths? Could you post a link to your page?
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #3
    Regular Coder
    Join Date
    Nov 2007
    Posts
    682
    Thanks
    319
    Thanked 1 Time in 1 Post
    Last edited by martynball; 04-06-2009 at 12:26 PM.

  • #4
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,861
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Your script has an error,
    Quote 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; 04-06-2009 at 01:45 PM.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • #5
    Regular Coder
    Join Date
    Nov 2007
    Posts
    682
    Thanks
    319
    Thanked 1 Time in 1 Post
    I havnt touched the javascript. I just uploaded it. Why was it working locally though?

  • #6
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,861
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    Quote 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.
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • Users who have thanked abduraooft for this post:

    martynball (04-06-2009)

  • #7
    Regular Coder
    Join Date
    Nov 2007
    Posts
    682
    Thanks
    319
    Thanked 1 Time in 1 Post
    Dont think I got it from there. Do you have a link?

  • #8
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,861
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • Users who have thanked abduraooft for this post:

    martynball (04-06-2009)

  • #9
    Regular Coder
    Join Date
    Nov 2007
    Posts
    682
    Thanks
    319
    Thanked 1 Time in 1 Post
    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?

  • #10
    Supreme Master coder! abduraooft's Avatar
    Join Date
    Mar 2007
    Location
    N/A
    Posts
    14,861
    Thanks
    160
    Thanked 2,223 Times in 2,210 Posts
    Blog Entries
    1
    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 )
    The Dream is not what you see in sleep; Dream is the thing which doesn't let you sleep. --(Dr. APJ. Abdul Kalam)

  • Users who have thanked abduraooft for this post:

    martynball (04-06-2009)

  • #11
    New Coder
    Join Date
    Mar 2009
    Posts
    28
    Thanks
    3
    Thanked 4 Times in 4 Posts
    Your style sheet tags aren't properly closed.
    Code:
    <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"/>

  • Users who have thanked F-b0mb for this post:

    martynball (04-06-2009)

  • #12
    Regular Coder
    Join Date
    Nov 2007
    Posts
    682
    Thanks
    319
    Thanked 1 Time in 1 Post
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •