View Full Version : Site loads slow in IE7, normal in Firefox

10-11-2008, 12:41 AM
First, I have to apologize, I don't know much about web development, just learning now.
My site is primarily php, but uses a few javascript. It was running fine until I added this script to the site. It's to enable users to choose how the site looks to them - a kind of template switcher. Now it loads extremely slow in IE7, but normal in Firefox and Chrome.
Can someone please take a look at this script and let me know if there is something obvious that would slow down the site in IE?
My site is www.eighthrealm.com.

Again, not sure if this is ok to post. If I am doing this wrong, I apologize...

var manual_or_random="manual"
var randomsetting="3 days"

function getCookie(Name) {
var re=new RegExp(Name+"=[^;]+", "i");
if (document.cookie.match(re))
return document.cookie.match(re)[0].split("=")[1]
return null

function setCookie(name, value, days) {
var expireDate = new Date()
var expstring=(typeof days!="undefined")? expireDate.setDate(expireDate.getDate()+parseInt(days)) : expireDate.setDate(expireDate.getDate()-5)
document.cookie = name+"="+value+"; expires="+expireDate.toGMTString()+"; path=/";

function deleteCookie(name){
setCookie(name, "moot")

function setStylesheet(title, randomize){
var i, cacheobj, altsheets=[""]
for(i=0; (cacheobj=document.getElementsByTagName("link")[i]); i++) {
if(cacheobj.getAttribute("rel").toLowerCase()=="alternate stylesheet" && cacheobj.getAttribute("title")) { //if this is an alternate stylesheet with title
cacheobj.disabled = true
if(cacheobj.getAttribute("title") == title)
cacheobj.disabled = false
if (typeof randomize!="undefined"){
var randomnumber=Math.floor(Math.random()*altsheets.length)
return (typeof randomize!="undefined" && altsheets[randomnumber]!="")? altsheets[randomnumber].getAttribute("title") : ""

function chooseStyle(styletitle, days){
if (document.getElementById){
setCookie("mysheet", styletitle, days)

function indicateSelected(element){
if (selectedtitle!=null && (element.type==undefined || element.type=="select-one")){
var element=(element.type=="select-one") ? element.options : element
for (var i=0; i<element.length; i++){
if (element[i].value==selectedtitle){
if (element[i].tagName=="OPTION")

if (manual_or_random=="manual"){
var selectedtitle=getCookie("mysheet")
if (document.getElementById && selectedtitle!=null)
else if (manual_or_random=="random"){
if (randomsetting=="eachtime")
setStylesheet("", "random")
else if (randomsetting=="sessiononly"){
if (getCookie("mysheet_s")==null)
document.cookie="mysheet_s="+setStylesheet("", "random")+"; path=/"
else if (randomsetting.search(/^[1-9]+ days/i)!=-1){
if (getCookie("mysheet_r")==null || parseInt(getCookie("mysheet_r_days"))!=parseInt(randomsetting)){
setCookie("mysheet_r", setStylesheet("", "random"), parseInt(randomsetting))
setCookie("mysheet_r_days", randomsetting, parseInt(randomsetting))

Thanks a bunch!
Devon :confused:

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum