Not signed in (Sign In)

SkillShare - A place to discuss Web Standards and Web Design topics

Categories

Vanilla 1.1.9 is a product of Lussumo. More Information: Documentation, Community Support.

    • CommentAuthorhebel
    • CommentTimeMay 11th 2007
     permalink
    I'm working on a new design of my site and I just installed the MS live search box (http://search.live.com/siteowner). It works fine but I think its javascript conflicts with the styleswitcher code I got from (http://alistapart.com/stories/alternate/). For some reason cookies now don't remember the style from the previous page. Would anyone have any idea how to rectify this?

    Hope I've supplied enough info.

    Thanks for any help.

    H.
  1.  permalink
    Helloooo!

    Where is the link?

    DS
    • CommentAuthorhebel
    • CommentTimeMay 11th 2007
     permalink
    Do you mean the link to my site? It's not up yet I am afraid. I'm testing it on my PC (amateur style)
  2.  permalink
    Yes that's what I meant.
    I don't think we can help you unless we can see it.

    Thanks
    • CommentAuthorhebel
    • CommentTimeMay 11th 2007
     permalink
    Does this help at all?

    This is the conflicting code. If I remove either the styleswitcher or live search everything works fine.


    ---HTML-----------------------------------------------

    <link rel="stylesheet" type="text/css" href="style1.css" title="style1" />
    <link rel="alternate stylesheet" type="text/css" href="style2.css" title="style2" />
    <script type="text/javascript" src="styleswitcher.js">
    </script>
    <script type="text/javascript">
    <!--
    window.onload=function(){
    var formref=document.getElementById("switchform")
    indicateSelected(formref.choice)
    }

    function MM_openBrWindow(theURL,winName,features) { //v2.0
    window.open(theURL,winName,features);
    }
    //-->
    </script>

    <div id="switch">
    <div class="switch2"><a href="#nogo" onclick="setActiveStyleSheet('style2'); return false;"><img src="images/largefont.jpg" /></a></div>
    <div class="switch1"><a href="#nogo" onclick="setActiveStyleSheet('style1'); return false;"><img src="images/smallfont.jpg" /></a></div>
    </div>


    ---STYLESWITCHER----------------------------------------

    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 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;
    }

    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;
    }

    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);
    }

    var cookie = readCookie("style");
    var title = cookie ? cookie : getPreferredStyleSheet();
    setActiveStyleSheet(title);


    ---LIVE SEARCH BOX------------------------------------------------

    <!-- Live Search -->
    <meta name="Search.WLSearchBox" content="1.1, en-GB" />
    <div id="WLSearchBoxDiv">
    <table cellpadding="0" cellspacing="0" style="width: 322px"><tr id="WLSearchBoxPlaceholder"><td style="width: 100%; border:solid 2px #4B7B9F;border-right-style: none;"><input id="WLSearchBoxInput" type="text" value="Loading..." disabled="disabled" style="padding:0;background-image: url(http://search.live.com/s/siteowner/searchbox_background.png);background-position: right;background-repeat: no-repeat;height: 16px; width: 100%; border:none 0 Transparent" /></td><td style="border:solid 2px #4B7B9F;"><input id="WLSearchBoxButton" type="image" src="http://search.live.com/s/siteowner/searchbutton_normal.png" align="absBottom" style="padding:0;border-style: none" /></td></tr></table>
    <script type="text/javascript" charset="utf-8">
    var WLSearchBoxConfiguration=
    {
    "global":{
    "serverDNS":"search.live.com",
    "market":"en-GB"
    },
    "appearance":{
    "autoHideTopControl":false,
    "width":600,
    "height":400,
    "theme":"Blue"
    },
    "scopes":[
    {
    "type":"web",
    "caption":"mysite",
    "searchParam":"site:www.mysite.com"
    }
    ,
    {
    "type":"web",
    "caption":"Web",
    "searchParam":""
    }
    ]
    }
    </script>
    <script type="text/javascript" charset="utf-8" src="http://search.live.com/bootstrap.js?market=en-GB&ServId=SearchBox&ServId=SearchBoxWeb&Callback=WLSearchBoxScriptReady"></script>
    </div>
    <!-- Live Search -->
  3.  permalink
    That is the source of the problem.
    <script type="text/javascript">
    <!--
    window.onload=function(){
    var formref=document.getElementById("switchform")
    indicateSelected(formref.choice)
    }

    function MM_openBrWindow(theURL,winName,features) { //v2.0
    window.open(theURL,winName,features);
    }
    //-->
    </script>
    they both using window.onload=function()
    to initiate on a page.

    you might try something like that not gurantee it will work
    Change this MS deal to
    <script type="text/javascript">
    <!--
    function mssearch(){
    var formref=document.getElementById("switchform")
    indicateSelected(formref.choice)
    }

    function MM_openBrWindow(theURL,winName,features) { //v2.0
    window.open(theURL,winName,features);
    }
    //-->
    </script>
    So we removing conflicting onload event then.
    in in body add <body onload="mssearch();">
    • CommentAuthorhebel
    • CommentTimeMay 11th 2007
     permalink
    Thanks for your help Dmitry but I am afraid it still doesn't work. All that happened is that the default smaller font is carried over to next pages. But really thanks for your suggestion.

    H.
  4.  permalink
    No problem!
    Is the any test website area where I can see it live?

    DS
    • CommentAuthorhebel
    • CommentTimeMay 12th 2007
     permalink
    afraid not. seems like a good idea though.
Add your comments
    Username Password
  • Format comments as (Help)