PDA

View Full Version : Switch Menu doesn't work in Safari



pawloui
06-03-2010, 08:34 AM
Hi there.

I have an annoying problem with må Switch Menu.

It works fine in Firefox, Explorer, Opera, Chrome but not in safari.

In safari all the switch menu are permanent open exept one of theme that works fine.

i've being trying for days to fix this probleme but I really can't figure it out.

Can anybody please help me?

Link to the site is: http://www.pawsfabrik.dk/lars/index.html

Sorry it is in danish

Thanx

Pawloui

azoomer
06-03-2010, 03:19 PM
Try this

<!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>
<link href="apple-touch-icon.png" rel="apple-touch-icon">
<link rel="shortcut icon" href="favicon.ico">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Reclaim Your Power</title>

<link href="larsdamkjaer.css" rel="stylesheet" type="text/css" />

<script type="text/javascript">
/***********************************************
* Switch Menu script- by Martial B of http://getElementById.com/
* Modified by Dynamic Drive for format & NS4/IE4 compatibility
* Visit http://www.dynamicdrive.com/ for full source code
***********************************************/

var persistmenu="yes" //"yes" or "no". Make sure each SPAN content contains an incrementing ID starting at 1 (id="sub1", id="sub2", etc)
var persisttype="sitewide" //enter "sitewide" for menu to persist across site, "local" for this page only

if (document.getElementById){ //DynamicDrive.com change
document.write('<style type="text/css">\n')
document.write('.submenu{display: none;}\n')
document.write('</style>\n')
}

function SwitchMenu(obj){
if(document.getElementById){
var el = document.getElementById(obj);
var ar = document.getElementById("masterdiv").getElementsByTagName("span"); //DynamicDrive.com change
if(el.style.display != "block"){ //DynamicDrive.com change
for (var i=0; i<ar.length; i++){
if (ar[i].className=="submenu") //DynamicDrive.com change
ar[i].style.display = "none";
}
el.style.display = "block";
}else{
el.style.display = "none";
}
}
}

function get_cookie(Name) {
var search = Name + "="
var returnvalue = "";
if (document.cookie.length > 0) {
offset = document.cookie.indexOf(search)
if (offset != -1) {
offset += search.length
end = document.cookie.indexOf(";", offset);
if (end == -1) end = document.cookie.length;
returnvalue=unescape(document.cookie.substring(offset, end))
}
}
return returnvalue;
}

function onloadfunction(){
if (persistmenu=="yes"){
var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname
var cookievalue=get_cookie(cookiename)
if (cookievalue!="")
document.getElementById(cookievalue).style.display="block"
}
}

function savemenustate(){
var inc=1, blockid=""
while (document.getElementById("sub"+inc)){
if (document.getElementById("sub"+inc).style.display=="block"){
blockid="sub"+inc
break
}
inc++
}
var cookiename=(persisttype=="sitewide")? "switchmenu" : window.location.pathname
var cookievalue=(persisttype=="sitewide")? blockid+";path=/" : blockid
document.cookie=cookiename+"="+cookievalue
}

if (window.addEventListener)
window.addEventListener("load", onloadfunction, false)
else if (window.attachEvent)
window.attachEvent("onload", onloadfunction)
else if (document.getElementById)
window.onload=onloadfunction

if (persistmenu=="yes" && document.getElementById)
window.onunload=savemenustate

function MM_preloadImages() { //v3.0
var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_swapImgRestore() { //v3.0
var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}
function MM_findObj(n, d) { //v4.01
var p,i,x; if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
</script>
<SCRIPT language="JavaScript">


var updateLayout = function() {
if (window.innerWidth != currentWidth) {
currentWidth = window.innerWidth;
var orient = (currentWidth == 320) ? "profile" : "landscape";
document.body.setAttribute("orient", orient);
window.scrollTo(0, 1);
}
};

iPhone.DomLoad(updateLayout);
setInterval(updateLayout, 500);

</SCRIPT>

</head>
<body>
<div id="wrapper">

<div id="language">
<span class="style33">
<a href="index.html">dansk</a>&nbsp;&nbsp;<a href="english/home.html">english</a>
</span>
</div>

<div id="header"><div id="logo1"><a href="index.html"><img src="logo/reclaimyourpower_logo.png" width="120" height="120" border="none" /></a></div>
<h1>Reclaim Your Power</h1>
<div id="logo2"><img src="logo/passionCoach.png" width="120" height="120" border="none" /></div>
</div>


<div id="content">
<div id="menu">
<div id="masterdiv">

<div class="menutitle" onclick="('sub1')"><a href="http://www.pawsfabrik.dk/lars/index.html">Profil</a></div>
<div class="menutitle" onclick="('sub1')"><a href="http://www.pawsfabrik.dk/lars/larsdamkjaer.html">Lars Damkjær</a></div>

<div class="menutitle" onclick="SwitchMenu('sub1')"><a href="#">Coaching</a></div>
<span style="display: none;" class="submenu" id="sub1">
<div class="submenu1"><a href="http://www.pawsfabrik.dk/lars/finddinpassion.html">FIND DIN PASSION™</a></div>
<div class="submenu1"><a href="http://www.pawsfabrik.dk/lars/udlevdinpassion.html">UDLEV DIN PASSION™</a></div>
<div class="submenu1"><a href="http://www.pawsfabrik.dk/lars/elskdinfrygt.html">ELSK DIN FRYGT™</a></div>
</span>

<div class="menutitle" onclick="SwitchMenu('sub2')"><a href="#">Rådgivning</a></div>
<span style="display: none;" class="submenu" id="sub2">
<div class="submenu1"><a href="http://www.pawsfabrik.dk/lars/mentorraadgivningforpionerer.html">MENTORRÅDGIVNING FOR PIONERER</a></div>
<div class="submenu1"><a href="http://www.pawsfabrik.dk/lars/3trinmoddroemmejobbet.html">3 TRIN MOD DRØMMEJOBBET</a></div>
</span>

<div class="menutitle" onclick="('sub1')"><a href="http://www.pawsfabrik.dk/lars/workshops.html">Workshops</a></div>

<div class="menutitle" onclick="SwitchMenu('sub3')"><a href="#">Retreats</a></div>
<span style="display: none;" class="submenu" id="sub3">
<div class="submenu1"><a href="http://www.pawsfabrik.dk/lars/retreats.html">PASSION RETREAT<br>I ITALIEN</a></div>
</span>

<div class="menutitle" onclick="('sub1')"><a href="http://www.pawsfabrik.dk/lars/priser.html">Priser</a></div>
<div class="menutitle" onclick="('sub1')"><a href="http://www.pawsfabrik.dk/lars/presse.html">Presse</a></div>
<div class="menutitle" onclick="('sub1')"><a href="http://www.pawsfabrik.dk/lars/nyhedsbrev.html">Nyhedsbrev</a></div>
<div class="menutitle" onclick="('sub1')"><a href="http://www.pawsfabrik.dk/lars/kontakt.html">Kontakt</a></div>

</div>

</div>


<div id="left">
<img src="billeder/lars/lars_profil.jpg" width="375" height="393" />
<div class="text"><p>Lars Damkjær Coaching tilbyder coachingforløb, mentorrådgivning for selvstændige, passion retreats og workshops. Firmaet blev stiftet i 2006 af cand. comm. og certificeret vejleder, life-, -business og passion coach™ Lars Damkjær.</p>
</div>
</div>

<div id="right">
<h2>Når vi ved, hvad vi brænder for, brænder vi lettere igennem i stedet for at brænde ud.
Men passionen skal vækkes til live, før den kan udfoldes!</h2>

<div class="text">
<p>Længes du efter et mere meningsfuldt liv og arbejdsliv?</p>
<p>Er du klar til at finde og udleve din passion NU?</p>
<p>Har du en fantastisk idé eller et projekt, som du ønsker at dele med verden men har brug for det sidste spark til at komme udover rampen?</p>
<p>Hvis du kan svare ja til mindst et af disse spørgsmål, så er jeg overbevist om, at du vil kunne få gavn af:</p>

<p><a href="finddinpassion.html"><strong>FIND DIN PASSION™</strong></a></p>

<p><a href="udlevdinpassion.html"><strong>UDLEV DIN PASSION™</strong></a></p>
<p><a href="elskdinfrygt.html"><strong>ELSK DIN FRYGT™</strong></a></p>
<p><a href="retreats.html"><strong>PASSION RETREAT I ITALIEN</strong></a></p>
<p><a href="mentorraadgivningforpionerer.html"><strong>MENTORRÅDGIVNING FOR PIONERER</strong></a></p>
<p><a href="3trinmoddroemmejobbet.html"><strong>3 TRIN MOD DRØMMEJOBBET</strong></a></p>

</div>

</div>
</div>

</div>

<div id="footer"><span class="style35">Lars&nbsp;Damkjær&nbsp;Coaching&nbsp;–&nbsp;CVR&nbsp;27547567&nbsp;–&nbsp;tlf:&nbsp;26180349&nbsp;–&nbsp;Skype:&nbsp;Larsdamkjaer&nbsp;copyright&nbsp;©&nbsp;Lars&nbsp;Damkjær&nbsp;2010</span></div>

</body>
</html>
Hope it works better !

pawloui
06-04-2010, 06:29 AM
Thanx Pal, it works.

You did only replace the a href with the http links instead?

Is it okay, it's not gonna slow down the download process of each page?

I will replace it when i'm done finishing the site

azoomer
06-04-2010, 06:51 AM
Lige nu kan ikke helt huske hvad det var jeg ændrede i går ( korttidshukommelsen du ved), men det ser ud til at det bare var afslutningen </a> som manglede !

<div class="menutitle" onclick="SwitchMenu('sub3')"><a href="#">Retreats</div>
bliver til:
<div class="menutitle" onclick="SwitchMenu('sub3')"><a href="#">Retreats</a></div>
og det samme for: rådgivning.


Det virker også hvis du helt fjerner linket
<div class="menutitle" onclick="SwitchMenu('sub3')">Retreats</div>

men så skifter det ikke farve når man musser over

pawloui
06-04-2010, 07:24 AM
Nåååår ja, det kan jeg godt se nu, jeg havde ikke afsluttet med et </a> tag, den må have været smuttet når jeg har copy/pasteet koden.

Det virker fuldstændigt nu, mange tak for hjælpen.

VH

Pawloui