...

View Full Version : how to add a textbrowser alternative to this js menu?



_Marcus
01-27-2009, 11:09 PM
hello,
my website tag7.ch consists of an html entry page and the main website. on the entry page there is a js menu that opens the main webpage in a new window in full screen.

I love this function but browser that don´t allow js doesn´t have a chance to enter the main website.

Do you know how the script has to be changed that there will be displayed some simple html text-links for non-js browser?

greetings from switzerland,
marcus
www.tag7.ch


<head>
<SCRIPT LANGUAGE="JavaScript">
function openPage(page, width, height, sBar) {
var w, h;
var agt = navigator.userAgent.toLowerCase();
var isNetscape = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1) && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1) && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
var isMac = (navigator.appVersion.indexOf("Mac") != -1);

w = (screen.availWidth ? screen.availWidth : 800);
h = (screen.availHeight ? screen.availHeight : 600);

var winObj = window.open("/_mini/"+page,"mini","left="+Math.round((w-width)/2)+",top="+Math.round((h-height)/2)+",width="+width+",height="+height+",fullscreen=no,scrollbars="+sBar);
}
function Pop(page){
switch(page){
case "test":
openPage("test.html", 350, 550, "yes");
break;

default:
break;
}
}


var hwin= null;
var fwin = null;

function enterFoo(){
openFullScreen();
//if (screen.width > 1024) openPopup();
//else openFullScreen();
//location.href = "thanks.html";
}
function enterFoo_en(){
openFullScreen_en();
//if (screen.width > 1024) openPopup();
//else openFullScreen();
//location.href = "thanks.html";
}
function openPopup(){
var popwidth=1024
var isMac = (navigator.appVersion.indexOf("Mac") != -1);
var winl = (screen.width-popwidth)/2;
var wint = (screen.height-700)/2;
if (isMac) wint += 30; // 20
else {
wint -= 20;
winl -= 10;
}
settings='height='+700+',width='+popwidth+',top='+wint+',left='+winl+',toolbar=no, location=no, menubar=no, status=no, scrollbars=yes, resizable=no'
fwin=window.open('main_de.html','.:Tag7:.',settings)
if(parseInt(navigator.appVersion) >= 4){fwin.window.focus();}
}
function openFullScreen() {
var width, height;
var agt = navigator.userAgent.toLowerCase();
var isNetscape = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1) && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1) && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
var isMac = (navigator.appVersion.indexOf("Mac") != -1);

width = (screen.availWidth ? screen.availWidth : 800);
height = (screen.availHeight ? screen.availHeight : 600);

height -= 35; // -20

if (isMac) height += 30; // 20
else width -= 10;

url = "main_de.htm";

var winObj = window.open(url,"Tag7","left=0,top=0,width=" + width + ",height=" + height + ",fullscreen=no, scrollbars=auto");
if(winObj && isMac && winObj.moveTo && winObj.resizeTo) {
winObj.moveTo(0, 0);
winObj.resizeTo((width), height);
winObj.focus();
}

}
function openFullScreen_en() {
var width, height;
var agt = navigator.userAgent.toLowerCase();
var isNetscape = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1) && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1) && (agt.indexOf('webtv')==-1) && (agt.indexOf('hotjava')==-1));
var isMac = (navigator.appVersion.indexOf("Mac") != -1);

width = (screen.availWidth ? screen.availWidth : 800);
height = (screen.availHeight ? screen.availHeight : 600);

height -= 35; // -20

if (isMac) height += 30; // 20
else width -= 10;

url = "main_en.htm";

var winObj = window.open(url,"Tag7","left=0,top=0,width=" + width + ",height=" + height + ",fullscreen=no, scrollbars=auto");
if(winObj && isMac && winObj.moveTo && winObj.resizeTo) {
winObj.moveTo(0, 0);
winObj.resizeTo((width), height);
winObj.focus();
}

}

function updateFlash(){
document.title = document.title.slice(0, 47) + " - Flash Player Installation";
}

</SCRIPT>

</head>

and


<body leftmargin="0" topmargin="0" bgcolor="#ffffff" marginheight="0" marginwidth="0">
<table border="0" cellpadding="0" cellspacing="0" height="100%" width="100%">
<tbody><tr>
<td align="center" valign="middle">
<br>&nbsp;
<br>&nbsp;
<br>&nbsp;
<br>&nbsp;
<br>&nbsp;
<br><img src="start_bild.jpg" usemap="#Map" border="0" height="379" width="265" alt="hochzeitsfotograf zürich schweiz">
<br>&nbsp;
<br>&nbsp;
<br>&nbsp;
<p></p>
</td>
</tr>
</tbody></table>


<map name="Map">
<area shape="rect" coords="41,332,222,349" href="http://blog.tag7.de/" target="_blank">
<area shape="rect" coords="41,261,222,278" href="javascript:enterFoo();">
<area shape="rect" coords="41,297,222,314" href="javascript:enterFoo_en();">
</map>

</body>

bunion
01-28-2009, 01:10 AM
<div id="nojs"><A>your links etc</a><div>

<script>
document.getElementById(nojs).innerHtml = "";
</script>


Try something like that. Might need to format the code properly. You place you links in a div, and if javascript is available, it will clear them.

_Marcus
01-28-2009, 10:27 AM
hello bunion,
thanks for your reply!

I tried but it doesn´t work. The html links are displayed even when my browser supports js. Where is the bug?

cheers, Marcus

[edit]
this is the result. the first 3 text links should not be visable on js browsers
http://tag7.ch/index_new.htm

rangana
01-28-2009, 11:22 AM
Try to surround the text menu with noscript tag:


<noscript>
Contents within this block are viewed only when users has JS disabled.
</noscript>


Also, it's better to design your page without JS yet, then add JS to add some interaction on your page.

Good links:
http://onlinetools.org/articles/unobtrusivejavascript/
http://www.alistapart.com/articles/understandingprogressiveenhancement

_Marcus
01-28-2009, 12:17 PM
@ rangana
thanks for your great and simple solution! it works just the way I needed it
:)

cheers, marcus



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum