This is a discussion on "live search code and styleswitcher code" within the JavaScript Forum section. This forum, and the thread "live search code and styleswitcher code are both part of the Program Your Website category.
|
|
|
|
|
![]() |
||
live search code and styleswitcher code
|
||
| Notices |
![]() |
|
|
LinkBack | Thread Tools |
|
|||
|
live search code and styleswitcher code
Hello, I'm working on a new design of my site and I just installed the MS live search box. It works fine but I think its javascript conflicts with the styleswitcher code I'm using. For some reason cookies don't remember the style from the previous page. I would really appreciate any suggestions.
Code is posted below: ---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/s...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=W LSearchBoxScriptReady"></script> </div> <!-- Live Search --> |
|
|
![]() |
| Tags |
| javascript, live search box, styleswitcher |
| Thread Tools | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Do search engines penalise websites using unoriginal source code? | TALLMALEUK | Search Engine Optimization (SEO) | 14 | Feb 25th, 2008 19:12 |
| code behind code doesnt work | skat | ASP.NET Forum | 4 | Feb 18th, 2008 10:05 |
| help! need search facility code to open in new window | metamuse | JavaScript Forum | 0 | Jul 15th, 2007 15:01 |
| I have some code but..... | hacker1312001 | Classic ASP | 1 | Apr 14th, 2006 02:43 |
| Can somebody give me the code to hide the source code? | renren | JavaScript Forum | 7 | Mar 7th, 2006 12:27 |