PDA

View Full Version : omni slide menu tricking browser into thinking javascript is disabled



gib65
08-07-2008, 04:11 AM
1) Script Title: omni slide menu

2) Script URL (on DD): http://www.dynamicdrive.com/dynamicindex1/omnislide/index.htm

3) Describe problem:

I have a couple omni slide menus on my website at http://www.mm-theory.com. It seems that when I have these menus up, my sidenote doesn't work. My sidenote is that little asterix in the left-hand margin that says "click me" underneath. If you click it, you get a page telling you javascript is disabled (even when it's enabled). I don't get this problem when I remove the menus.

The code for the asterix link is as follows:



<a class="margin_icon" onclick="openWin('deeper_problem.htm','',600,1);return false;" href="enablejs.htm" target=_blank>
<img class="margin_icon" src="icons/side.gif" alt="side.gif" border=0>
<br>
<span class="margin_icon">
Click Me!
</span>
</a>


The code for the openwin function is as follows:



function openWin(url,name,wid,hgt) {
sw=(screen.width-wid)/2;
sh=(screen.height-hgt)/2;
newwin=window.open(url,name,'width='+wid+',height='+hgt+',top='+sh+'+sh+',left='+sw+',scrollbars=0,menubars=0,toolbars=0,directories=0,location=0,address=0');
mewwin.focus();
}


This function is made available on the home page I linked you to (http://www.mm-theory.com) by the following code in the head section:



<script language="javascript" type="text/javascript" src="openwin.txt"></script>


Can anyone tell me why it says I need to enable javascript when javascript is already enabled?

jscheuer1
08-07-2008, 06:28 AM
All I get is a pop up with:


Actually, for those well versed in the neurosciences, the problem is even more complicated than this. For them, the question is how does free-will fit into a brain that seems almost completely deterministic?

I tested in IE 6 & 7, FF 3, Opera 9.52, and Safari 3 Win. There was one problem. In Opera, it actually allows a 1px high window, so I had to use the mouse to enlarge the pop up, you should use something like:


onclick="openWin('deeper_problem.htm','',600,100);return false;"

to prevent that. What browser and OS are you using?

Just to be on the safe side, your openWin function should be changed to:


function openWin(url,name,wid,hgt) {
var sw=(screen.width-wid)/2;
var sh=(screen.height-hgt)/2;
var newwin=window.open(url,name,'width='+wid+',height='+hgt+',top='+sh+'+sh+',left='+sw+',scrollbars=0,menubars=0,toolbars=0,directories=0,location=0,address=0');
newwin.focus();
}

And get rid of this:


<script language="JavaScript">
<!--

function SymError()
{
return true;
}

window.onerror = SymError;

var SymRealWinOpen = window.open;

function SymWinOpen(url, name, attributes)
{
return (new Object());
}

window.open = SymWinOpen;

//-->
</script>


And get rid of this:


<script language="JavaScript">
<!--
var SymRealOnLoad;
var SymRealOnUnload;

function SymOnUnload()
{
window.open = SymWinOpen;
if(SymRealOnUnload != null)
SymRealOnUnload();
}

function SymOnLoad()
{
if(SymRealOnLoad != null)
SymRealOnLoad();
window.open = SymRealWinOpen;
SymRealOnUnload = window.onunload;
window.onunload = SymOnUnload;
}

SymRealOnLoad = window.onload;
window.onload = SymOnLoad;

//-->
</script>

Oh, and one more bit, change this:


<script language="javascript" type="text/javascript" src="openwin.txt"></script>

to:


<script type="text/javascript" src="openwin.js"></script>

and rename the file openwin.txt to openwin.js

gib65
08-07-2008, 02:14 PM
OMG, it worked!!!

Thanks so much, jscheuer1!

It doesn't surprise me that you weren't able to replicate the problem at your end. It seems to work fine on some computers and not others. I get the problem at home but not at work. I have IE 6.0 and FF 5.0 on both, and which browser I use doesn't seem to make a difference.

Very strange that getting rid of the code in omnimenu_body.inc was necessary, especially since the code you told me to get rid of was ALL the code in that file (essentially I deleted the file and removed my reference to it in the body of my html page). According to DD's specs on the omni slide menu, I needed that code.

jscheuer1
08-07-2008, 02:58 PM
Very strange that getting rid of the code in omnimenu_body.inc was necessary, especially since the code you told me to get rid of was ALL the code in that file (essentially I deleted the file and removed my reference to it in the body of my html page). According to DD's specs on the omni slide menu, I needed that code.

If you are referring to this code:


<script language="JavaScript">
<!--

function SymError()
{
return true;
}

window.onerror = SymError;

var SymRealWinOpen = window.open;

function SymWinOpen(url, name, attributes)
{
return (new Object());
}

window.open = SymWinOpen;

//-->
</script>

and this:


<script language="JavaScript">
<!--
var SymRealOnLoad;
var SymRealOnUnload;

function SymOnUnload()
{
window.open = SymWinOpen;
if(SymRealOnUnload != null)
SymRealOnUnload();
}

function SymOnLoad()
{
if(SymRealOnLoad != null)
SymRealOnLoad();
window.open = SymRealWinOpen;
SymRealOnUnload = window.onunload;
window.onunload = SymOnUnload;
}

SymRealOnLoad = window.onload;
window.onload = SymOnLoad;

//-->
</script>

I wrote Omni Slide and it doesn't require it. If the demo page (the one Dynamic Drive) says that it does, it's wrong. If you got the code from somewhere else, the recommendation to use the above may have been either in reference to a specific objective that isn't part of the main Omni Slide code, or just incidental as the result of some editor, somewhere along the way adding that code - some editors do that. If you did get the code from DD, I just checked - it doesn't have the above, your editor may have added it.

gib65
08-07-2008, 04:17 PM
That may be it. I got that code by visiting the demo.htm page and viewing the source code.